feat: display bloom filter usage
This commit is contained in:
parent
033fb3637d
commit
1969130fad
|
@ -36,5 +36,6 @@ proc init*(self: NodeController) =
|
||||||
|
|
||||||
self.status.events.on(SignalType.Stats.event) do (e:Args):
|
self.status.events.on(SignalType.Stats.event) do (e:Args):
|
||||||
self.view.setStats(StatsSignal(e).stats)
|
self.view.setStats(StatsSignal(e).stats)
|
||||||
|
self.view.getBitsSet()
|
||||||
|
|
||||||
self.view.init()
|
self.view.init()
|
||||||
|
|
|
@ -1,10 +1,30 @@
|
||||||
import NimQml, chronicles, strutils, json
|
import NimQml, chronicles, strutils, json
|
||||||
import ../../status/[status, node, types, settings, accounts]
|
import ../../status/[status, node, types, settings, accounts]
|
||||||
import ../../status/signals/types as signal_types
|
import ../../status/signals/types as signal_types
|
||||||
|
import ../../status/tasks/[qt, task_runner_impl]
|
||||||
|
|
||||||
logScope:
|
logScope:
|
||||||
topics = "node-view"
|
topics = "node-view"
|
||||||
|
|
||||||
|
type
|
||||||
|
BloomBitsSetTaskArg = ref object of QObjectTaskArg
|
||||||
|
bitsSet: int
|
||||||
|
|
||||||
|
const bloomBitsSetTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} =
|
||||||
|
let
|
||||||
|
arg = decode[BloomBitsSetTaskArg](argEncoded)
|
||||||
|
output = getBloomFilterBitsSet(nil)
|
||||||
|
arg.finish(output)
|
||||||
|
|
||||||
|
proc bloomFiltersBitsSet[T](self: T, slot: string) =
|
||||||
|
let arg = BloomBitsSetTaskArg(
|
||||||
|
tptr: cast[ByteAddress](bloomBitsSetTask),
|
||||||
|
vptr: cast[ByteAddress](self.vptr),
|
||||||
|
slot: slot
|
||||||
|
)
|
||||||
|
self.status.tasks.threadpool.start(arg)
|
||||||
|
|
||||||
|
|
||||||
QtObject:
|
QtObject:
|
||||||
type NodeView* = ref object of QObject
|
type NodeView* = ref object of QObject
|
||||||
status*: Status
|
status*: Status
|
||||||
|
@ -14,6 +34,7 @@ QtObject:
|
||||||
fullNode*: bool
|
fullNode*: bool
|
||||||
stats*: Stats
|
stats*: Stats
|
||||||
peerSize: int
|
peerSize: int
|
||||||
|
bloomBitsSet: int
|
||||||
|
|
||||||
proc setup(self: NodeView) =
|
proc setup(self: NodeView) =
|
||||||
self.QObject.setup
|
self.QObject.setup
|
||||||
|
@ -133,6 +154,22 @@ QtObject:
|
||||||
self.stats = stats
|
self.stats = stats
|
||||||
self.statsChanged()
|
self.statsChanged()
|
||||||
|
|
||||||
|
proc getBitsSet*(self: NodeView) =
|
||||||
|
self.bloomFiltersBitsSet("bitsSet")
|
||||||
|
|
||||||
|
proc getBloomBitsSet(self: NodeView): int {.slot.} =
|
||||||
|
self.bloomBitsSet
|
||||||
|
|
||||||
|
proc bloomBitsSetChanged(self: NodeView) {.signal.}
|
||||||
|
|
||||||
|
proc bitsSet*(self: NodeView, bitsSet: string) {.slot.} =
|
||||||
|
self.bloomBitsSet = parseInt(bitsSet)
|
||||||
|
self.bloomBitsSetChanged();
|
||||||
|
|
||||||
|
QtProperty[int] bloomBits:
|
||||||
|
read = getBloomBitsSet
|
||||||
|
notify = bloomBitsSetChanged
|
||||||
|
|
||||||
proc uploadRate*(self: NodeView): string {.slot.} = $self.stats.uploadRate
|
proc uploadRate*(self: NodeView): string {.slot.} = $self.stats.uploadRate
|
||||||
|
|
||||||
QtProperty[string] uploadRate:
|
QtProperty[string] uploadRate:
|
||||||
|
|
|
@ -162,9 +162,9 @@ var NODE_CONFIG* = %* {
|
||||||
"URL": "https://mainnet.infura.io/v3/" & INFURA_TOKEN_RESOLVED
|
"URL": "https://mainnet.infura.io/v3/" & INFURA_TOKEN_RESOLVED
|
||||||
},
|
},
|
||||||
"WakuConfig": {
|
"WakuConfig": {
|
||||||
"BloomFilterMode": false,
|
"BloomFilterMode": true,
|
||||||
"Enabled": true,
|
"Enabled": true,
|
||||||
"LightClient": false,
|
"LightClient": true,
|
||||||
"MinimumPoW": 0.001
|
"MinimumPoW": 0.001
|
||||||
},
|
},
|
||||||
"WakuV2Config": {
|
"WakuV2Config": {
|
||||||
|
|
|
@ -57,3 +57,6 @@ proc signMessage*(rpcParams: string): string =
|
||||||
|
|
||||||
proc signTypedData*(data: string, address: string, password: string): string =
|
proc signTypedData*(data: string, address: string, password: string): string =
|
||||||
return $status_go.signTypedData(data, address, password)
|
return $status_go.signTypedData(data, address, password)
|
||||||
|
|
||||||
|
proc getBloomFilter*(): string =
|
||||||
|
return $callPrivateRPC("bloomFilter".prefix, %* []).parseJSON()["result"].getStr
|
||||||
|
|
|
@ -192,6 +192,7 @@ proc setBloomLevel*(bloomFilterMode: bool, fullNode: bool): StatusGoError =
|
||||||
var nodeConfig = getNodeConfig()
|
var nodeConfig = getNodeConfig()
|
||||||
nodeConfig["WakuConfig"]["BloomFilterMode"] = newJBool(bloomFilterMode)
|
nodeConfig["WakuConfig"]["BloomFilterMode"] = newJBool(bloomFilterMode)
|
||||||
nodeConfig["WakuConfig"]["FullNode"] = newJBool(fullNode)
|
nodeConfig["WakuConfig"]["FullNode"] = newJBool(fullNode)
|
||||||
|
nodeConfig["WakuConfig"]["LightClient"] = newJBool(not fullNode)
|
||||||
return saveSetting(Setting.NodeConfig, nodeConfig)
|
return saveSetting(Setting.NodeConfig, nodeConfig)
|
||||||
|
|
||||||
proc setFleet*(fleetConfig: FleetConfig, fleet: Fleet): StatusGoError =
|
proc setFleet*(fleetConfig: FleetConfig, fleet: Fleet): StatusGoError =
|
||||||
|
|
|
@ -5,6 +5,7 @@ import types as libstatus_types
|
||||||
import chat, accounts, wallet, node, network, messages, contacts, profile, stickers, permissions, fleet, settings, mailservers, browser, tokens, provider
|
import chat, accounts, wallet, node, network, messages, contacts, profile, stickers, permissions, fleet, settings, mailservers, browser, tokens, provider
|
||||||
import ../eventemitter
|
import ../eventemitter
|
||||||
import ./tasks/task_runner_impl
|
import ./tasks/task_runner_impl
|
||||||
|
import bitops, stew/byteutils, chronicles
|
||||||
|
|
||||||
export chat, accounts, node, messages, contacts, profile, network, permissions, fleet, task_runner_impl, eventemitter
|
export chat, accounts, node, messages, contacts, profile, network, permissions, fleet, task_runner_impl, eventemitter
|
||||||
|
|
||||||
|
@ -75,3 +76,13 @@ proc getNodeVersion*(self: Status): string =
|
||||||
# TODO: duplicated??
|
# TODO: duplicated??
|
||||||
proc saveSetting*(self: Status, setting: Setting, value: string | bool) =
|
proc saveSetting*(self: Status, setting: Setting, value: string | bool) =
|
||||||
discard libstatus_settings.saveSetting(setting, value)
|
discard libstatus_settings.saveSetting(setting, value)
|
||||||
|
|
||||||
|
proc getBloomFilter*(self: Status): string =
|
||||||
|
result = libstatus_core.getBloomFilter()
|
||||||
|
|
||||||
|
proc getBloomFilterBitsSet*(self: Status): int =
|
||||||
|
let bloomFilter = libstatus_core.getBloomFilter()
|
||||||
|
var bitCount = 0;
|
||||||
|
for b in hexToSeqByte(bloomFilter):
|
||||||
|
bitCount += countSetBits(b)
|
||||||
|
return bitCount
|
|
@ -45,6 +45,30 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
id: bloomF
|
||||||
|
Layout.fillWidth: true
|
||||||
|
StyledText {
|
||||||
|
color: Style.current.lightBlueText
|
||||||
|
text: "Bloom Filter Usage"
|
||||||
|
Layout.rightMargin: Style.current.padding
|
||||||
|
Layout.leftMargin: Style.current.padding
|
||||||
|
Layout.fillWidth: true
|
||||||
|
font.weight: Font.Medium
|
||||||
|
font.pixelSize: 20
|
||||||
|
}
|
||||||
|
StyledText {
|
||||||
|
id: bloomPerc
|
||||||
|
color: Style.current.lightBlueText
|
||||||
|
text: ((nodeModel.bloomBits / 512) * 100).toFixed(2) + "%"
|
||||||
|
Layout.rightMargin: Style.current.padding
|
||||||
|
Layout.leftMargin: Style.current.padding
|
||||||
|
Layout.fillWidth: true
|
||||||
|
font.weight: Font.Medium
|
||||||
|
font.pixelSize: 20
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
id: messageContainer
|
id: messageContainer
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
|
|
Loading…
Reference in New Issue