mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-02-07 07:23:07 +00:00
add apis to know peercounts
This commit is contained in:
parent
129b6fe43e
commit
4198a50cd1
@ -9,6 +9,7 @@ import
|
||||
metrics,
|
||||
ffi
|
||||
import waku/factory/waku, waku/node/waku_node, waku/node/health_monitor, library/declare_lib
|
||||
import waku/waku_core/codecs
|
||||
|
||||
proc getMultiaddresses(node: WakuNode): seq[string] =
|
||||
return node.info().listenAddresses
|
||||
@ -47,3 +48,18 @@ proc waku_is_online(
|
||||
ctx: ptr FFIContext[Waku], callback: FFICallBack, userData: pointer
|
||||
) {.ffi.} =
|
||||
return ok($ctx.myLib[].healthMonitor.onlineMonitor.amIOnline())
|
||||
|
||||
proc waku_get_mixnode_pool_size(
|
||||
ctx: ptr FFIContext[Waku], callback: FFICallBack, userData: pointer
|
||||
) {.ffi.} =
|
||||
## Returns the number of mix nodes in the pool
|
||||
if ctx.myLib[].node.wakuMix.isNil():
|
||||
return ok("0")
|
||||
return ok($ctx.myLib[].node.getMixNodePoolSize())
|
||||
|
||||
proc waku_get_lightpush_peers_count(
|
||||
ctx: ptr FFIContext[Waku], callback: FFICallBack, userData: pointer
|
||||
) {.ffi.} =
|
||||
## Returns the count of all peers in peerstore supporting lightpush protocol
|
||||
let peers = ctx.myLib[].node.peerManager.switch.peerStore.getPeersByProtocol(WakuLightPushCodec)
|
||||
return ok($peers.len)
|
||||
|
||||
@ -8,8 +8,13 @@ import
|
||||
waku/waku_store/common,
|
||||
waku/waku_store/client,
|
||||
waku/common/paging,
|
||||
waku/common/base64,
|
||||
library/declare_lib
|
||||
|
||||
# Custom JSON serialization for seq[byte] to avoid ambiguity
|
||||
proc `%`*(data: seq[byte]): JsonNode =
|
||||
%base64.encode(data)
|
||||
|
||||
func fromJsonNode(jsonContent: JsonNode): Result[StoreQueryRequest, string] =
|
||||
var contentTopics: seq[string]
|
||||
if jsonContent.contains("contentTopics"):
|
||||
@ -90,5 +95,6 @@ proc waku_store_query(
|
||||
).valueOr:
|
||||
return err("StoreRequest failed store query: " & $error)
|
||||
|
||||
let res = $(%*(queryResponse.toHex()))
|
||||
let hexResponse = queryResponse.toHex()
|
||||
let res = $(%*hexResponse)
|
||||
return ok(res) ## returning the response in json format
|
||||
|
||||
@ -5,10 +5,10 @@ filter = true
|
||||
store = false
|
||||
lightpush = true
|
||||
max-connections = 150
|
||||
peer-exchange = false
|
||||
peer-exchange = true
|
||||
metrics-logging = false
|
||||
cluster-id = 2
|
||||
discv5-discovery = false
|
||||
discv5-discovery = true
|
||||
discv5-udp-port = 9000
|
||||
discv5-enr-auto-update = true
|
||||
enable-kad-discovery = true
|
||||
@ -20,7 +20,7 @@ shard = [0]
|
||||
agent-string = "nwaku-mix"
|
||||
nodekey = "f98e3fba96c32e8d1967d460f1b79457380e1a895f7971cecc8528abe733781a"
|
||||
mixkey = "a87db88246ec0eedda347b9b643864bee3d6933eb15ba41e6d58cb678d813258"
|
||||
rendezvous = false
|
||||
rendezvous = true
|
||||
listen-address = "127.0.0.1"
|
||||
nat = "extip:127.0.0.1"
|
||||
ext-multiaddr = ["/ip4/127.0.0.1/tcp/60001"]
|
||||
|
||||
@ -5,12 +5,12 @@ filter = true
|
||||
store = false
|
||||
lightpush = true
|
||||
max-connections = 150
|
||||
peer-exchange = false
|
||||
peer-exchange = true
|
||||
metrics-logging = false
|
||||
cluster-id = 2
|
||||
discv5-discovery = false
|
||||
discv5-discovery = true
|
||||
discv5-udp-port = 9001
|
||||
discv5-enr-auto-update = false
|
||||
discv5-enr-auto-update = true
|
||||
discv5-bootstrap-node = ["enr:-LG4QBaAbcA921hmu3IrreLqGZ4y3VWCjBCgNN9mpX9vqkkbSrM3HJHZTXnb5iVXgc5pPtDhWLxkB6F3yY25hSwMezkEgmlkgnY0gmlwhH8AAAGKbXVsdGlhZGRyc4oACATAqEQ-BuphgnJzhQACAQAAiXNlY3AyNTZrMaEDpEW1UlUGHRJg6g_zGuCddKWmIUBGZCQX13xGfh9J6KiDdGNwguphg3VkcIIjKYV3YWt1Mg0"]
|
||||
kad-bootstrap-node = ["/ip4/127.0.0.1/tcp/60001/p2p/16Uiu2HAmPiEs2ozjjJF2iN2Pe2FYeMC9w4caRHKYdLdAfjgbWM6o"]
|
||||
rest = true
|
||||
@ -21,7 +21,7 @@ shard = [0]
|
||||
agent-string = "nwaku-mix"
|
||||
nodekey = "09e9d134331953357bd38bbfce8edb377f4b6308b4f3bfbe85c610497053d684"
|
||||
mixkey = "c86029e02c05a7e25182974b519d0d52fcbafeca6fe191fbb64857fb05be1a53"
|
||||
rendezvous = false
|
||||
rendezvous = true
|
||||
listen-address = "127.0.0.1"
|
||||
nat = "extip:127.0.0.1"
|
||||
ext-multiaddr = ["/ip4/127.0.0.1/tcp/60002"]
|
||||
|
||||
@ -5,12 +5,12 @@ filter = true
|
||||
store = false
|
||||
lightpush = true
|
||||
max-connections = 150
|
||||
peer-exchange = false
|
||||
peer-exchange = true
|
||||
metrics-logging = false
|
||||
cluster-id = 2
|
||||
discv5-discovery = false
|
||||
discv5-discovery = true
|
||||
discv5-udp-port = 9002
|
||||
discv5-enr-auto-update = false
|
||||
discv5-enr-auto-update = true
|
||||
discv5-bootstrap-node = ["enr:-LG4QBaAbcA921hmu3IrreLqGZ4y3VWCjBCgNN9mpX9vqkkbSrM3HJHZTXnb5iVXgc5pPtDhWLxkB6F3yY25hSwMezkEgmlkgnY0gmlwhH8AAAGKbXVsdGlhZGRyc4oACATAqEQ-BuphgnJzhQACAQAAiXNlY3AyNTZrMaEDpEW1UlUGHRJg6g_zGuCddKWmIUBGZCQX13xGfh9J6KiDdGNwguphg3VkcIIjKYV3YWt1Mg0"]
|
||||
kad-bootstrap-node = ["/ip4/127.0.0.1/tcp/60001/p2p/16Uiu2HAmPiEs2ozjjJF2iN2Pe2FYeMC9w4caRHKYdLdAfjgbWM6o"]
|
||||
rest = false
|
||||
@ -21,7 +21,7 @@ shard = [0]
|
||||
agent-string = "nwaku-mix"
|
||||
nodekey = "ed54db994682e857d77cd6fb81be697382dc43aa5cd78e16b0ec8098549f860e"
|
||||
mixkey = "b858ac16bbb551c4b2973313b1c8c8f7ea469fca03f1608d200bbf58d388ec7f"
|
||||
rendezvous = false
|
||||
rendezvous = true
|
||||
listen-address = "127.0.0.1"
|
||||
nat = "extip:127.0.0.1"
|
||||
ext-multiaddr = ["/ip4/127.0.0.1/tcp/60003"]
|
||||
|
||||
@ -5,12 +5,12 @@ filter = true
|
||||
store = false
|
||||
lightpush = true
|
||||
max-connections = 150
|
||||
peer-exchange = false
|
||||
peer-exchange = true
|
||||
metrics-logging = false
|
||||
cluster-id = 2
|
||||
discv5-discovery = false
|
||||
discv5-discovery = true
|
||||
discv5-udp-port = 9003
|
||||
discv5-enr-auto-update = false
|
||||
discv5-enr-auto-update = true
|
||||
discv5-bootstrap-node = ["enr:-LG4QBaAbcA921hmu3IrreLqGZ4y3VWCjBCgNN9mpX9vqkkbSrM3HJHZTXnb5iVXgc5pPtDhWLxkB6F3yY25hSwMezkEgmlkgnY0gmlwhH8AAAGKbXVsdGlhZGRyc4oACATAqEQ-BuphgnJzhQACAQAAiXNlY3AyNTZrMaEDpEW1UlUGHRJg6g_zGuCddKWmIUBGZCQX13xGfh9J6KiDdGNwguphg3VkcIIjKYV3YWt1Mg0"]
|
||||
kad-bootstrap-node = ["/ip4/127.0.0.1/tcp/60001/p2p/16Uiu2HAmPiEs2ozjjJF2iN2Pe2FYeMC9w4caRHKYdLdAfjgbWM6o"]
|
||||
rest = false
|
||||
@ -21,7 +21,7 @@ shard = [0]
|
||||
agent-string = "nwaku-mix"
|
||||
nodekey = "42f96f29f2d6670938b0864aced65a332dcf5774103b4c44ec4d0ea4ef3c47d6"
|
||||
mixkey = "d8bd379bb394b0f22dd236d63af9f1a9bc45266beffc3fbbe19e8b6575f2535b"
|
||||
rendezvous = false
|
||||
rendezvous = true
|
||||
listen-address = "127.0.0.1"
|
||||
nat = "extip:127.0.0.1"
|
||||
ext-multiaddr = ["/ip4/127.0.0.1/tcp/60004"]
|
||||
|
||||
@ -5,12 +5,12 @@ filter = true
|
||||
store = false
|
||||
lightpush = true
|
||||
max-connections = 150
|
||||
peer-exchange = false
|
||||
peer-exchange = true
|
||||
metrics-logging = false
|
||||
cluster-id = 2
|
||||
discv5-discovery = false
|
||||
discv5-discovery = true
|
||||
discv5-udp-port = 9004
|
||||
discv5-enr-auto-update = false
|
||||
discv5-enr-auto-update = true
|
||||
discv5-bootstrap-node = ["enr:-LG4QBaAbcA921hmu3IrreLqGZ4y3VWCjBCgNN9mpX9vqkkbSrM3HJHZTXnb5iVXgc5pPtDhWLxkB6F3yY25hSwMezkEgmlkgnY0gmlwhH8AAAGKbXVsdGlhZGRyc4oACATAqEQ-BuphgnJzhQACAQAAiXNlY3AyNTZrMaEDpEW1UlUGHRJg6g_zGuCddKWmIUBGZCQX13xGfh9J6KiDdGNwguphg3VkcIIjKYV3YWt1Mg0"]
|
||||
kad-bootstrap-node = ["/ip4/127.0.0.1/tcp/60001/p2p/16Uiu2HAmPiEs2ozjjJF2iN2Pe2FYeMC9w4caRHKYdLdAfjgbWM6o"]
|
||||
rest = false
|
||||
@ -21,7 +21,7 @@ shard = [0]
|
||||
agent-string = "nwaku-mix"
|
||||
nodekey = "3ce887b3c34b7a92dd2868af33941ed1dbec4893b054572cd5078da09dd923d4"
|
||||
mixkey = "780fff09e51e98df574e266bf3266ec6a3a1ddfcf7da826a349a29c137009d49"
|
||||
rendezvous = false
|
||||
rendezvous = true
|
||||
listen-address = "127.0.0.1"
|
||||
nat = "extip:127.0.0.1"
|
||||
ext-multiaddr = ["/ip4/127.0.0.1/tcp/60005"]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user