mirror of
https://github.com/logos-messaging/logos-delivery.git
synced 2026-04-15 12:43:07 +00:00
renaming, logs & fixes
This commit is contained in:
parent
8b9ac897e2
commit
74a3fcffd3
@ -17,7 +17,7 @@ import
|
||||
import waku/waku_core, waku/node/peer_manager
|
||||
|
||||
logScope:
|
||||
topics = "waku kademlia discovery"
|
||||
topics = "waku kademlia"
|
||||
|
||||
const DefaultKademliaDiscoveryInterval* = chronos.seconds(10)
|
||||
|
||||
@ -68,7 +68,7 @@ proc toRemotePeerInfo(record: ExtendedPeerRecord): Option[RemotePeerInfo] =
|
||||
proc runDiscoveryLoop(
|
||||
self: WakuKademlia, interval: Duration
|
||||
) {.async: (raises: [CancelledError]).} =
|
||||
info "kademlia discovery loop started", interval = interval
|
||||
debug "kademlia discovery loop started", interval = interval
|
||||
|
||||
while true:
|
||||
await sleepAsync(interval)
|
||||
@ -130,7 +130,7 @@ proc new*(
|
||||
providedServices: var seq[ServiceInfo],
|
||||
): T =
|
||||
if bootstrapNodes.len == 0:
|
||||
info "creating kademlia discovery as seed node (no bootstrap nodes)"
|
||||
debug "creating kademlia discovery as seed node (no bootstrap nodes)"
|
||||
|
||||
let kademlia = KademliaDiscovery.new(
|
||||
switch,
|
||||
@ -141,13 +141,11 @@ proc new*(
|
||||
services = providedServices,
|
||||
)
|
||||
|
||||
info "kademlia service discovery created", bootstrapNodes = bootstrapNodes.len
|
||||
|
||||
return WakuKademlia(protocol: kademlia, peerManager: peerManager)
|
||||
|
||||
proc start*(
|
||||
self: WakuKademlia, interval: Duration = DefaultKademliaDiscoveryInterval
|
||||
) {.async: (raises: [CancelledError]).} =
|
||||
) {.async.} =
|
||||
if self.protocol.started:
|
||||
warn "Starting waku kad twice"
|
||||
return
|
||||
@ -160,7 +158,7 @@ proc start*(
|
||||
|
||||
info "Waku Kademlia Started"
|
||||
|
||||
proc stop*(self: WakuKademlia) {.async: (raises: []).} =
|
||||
proc stop*(self: WakuKademlia) {.async.} =
|
||||
if not self.protocol.started:
|
||||
return
|
||||
|
||||
|
||||
@ -476,12 +476,6 @@ proc startNode*(
|
||||
if conf.relay:
|
||||
node.peerManager.start()
|
||||
|
||||
if not node.wakuKademlia.isNil():
|
||||
let catchRes = catch:
|
||||
await node.wakuKademlia.start()
|
||||
if catchRes.isErr():
|
||||
return err("failed to start kademlia discovery: " & catchRes.error.msg)
|
||||
|
||||
return ok()
|
||||
|
||||
proc setupNode*(
|
||||
|
||||
@ -604,6 +604,9 @@ proc start*(node: WakuNode) {.async.} =
|
||||
if not node.wakuStoreTransfer.isNil():
|
||||
node.wakuStoreTransfer.start()
|
||||
|
||||
if not node.wakuKademlia.isNil():
|
||||
await node.wakuKademlia.start()
|
||||
|
||||
## The switch uses this mapper to update peer info addrs
|
||||
## with announced addrs after start
|
||||
let addressMapper = proc(
|
||||
@ -664,15 +667,15 @@ proc stop*(node: WakuNode) {.async.} =
|
||||
not node.wakuPeerExchangeClient.pxLoopHandle.isNil():
|
||||
await node.wakuPeerExchangeClient.pxLoopHandle.cancelAndWait()
|
||||
|
||||
if not node.wakuKademlia.isNil():
|
||||
await node.wakuKademlia.stop()
|
||||
|
||||
if not node.wakuRendezvous.isNil():
|
||||
await node.wakuRendezvous.stopWait()
|
||||
|
||||
if not node.wakuRendezvousClient.isNil():
|
||||
await node.wakuRendezvousClient.stopWait()
|
||||
|
||||
if not node.wakuKademlia.isNil():
|
||||
await node.wakuKademlia.stop()
|
||||
|
||||
node.started = false
|
||||
|
||||
proc isReady*(node: WakuNode): Future[bool] {.async: (raises: [Exception]).} =
|
||||
|
||||
@ -45,7 +45,7 @@ proc poolSize*(self: WakuMix): int =
|
||||
proc mixPoolMaintenance(
|
||||
self: WakuMix, interval: Duration
|
||||
) {.async: (raises: [CancelledError]).} =
|
||||
## Periodic maintenance of the mix pool
|
||||
debug "mix pool maintenance loop started", interval = interval
|
||||
|
||||
while true:
|
||||
await sleepAsync(interval)
|
||||
@ -61,12 +61,12 @@ proc mixPoolMaintenance(
|
||||
debug "kademlia not available for mix peer discovery"
|
||||
continue
|
||||
|
||||
debug "mix node pool below threshold, performing targeted lookup",
|
||||
trace "mix node pool below threshold, performing targeted lookup",
|
||||
currentPoolSize = self.currentMixPoolSize, threshold = self.targetMixPoolSize
|
||||
|
||||
let mixPeers = await self.wakuKademlia.lookup(MixProtocolID)
|
||||
|
||||
debug "mix peer discovery completed", discoveredPeers = mixPeers.len
|
||||
trace "mix peer discovery completed", discoveredPeers = mixPeers.len
|
||||
|
||||
proc new*(
|
||||
T: typedesc[WakuMix],
|
||||
@ -79,7 +79,7 @@ proc new*(
|
||||
): Result[T, string] =
|
||||
let mixPubKey = public(mixPrivKey)
|
||||
|
||||
info "mixPubKey", mixPubKey = mixPubKey
|
||||
debug "Mix Public Key", mixPubKey = mixPubKey
|
||||
|
||||
let nodeMultiAddr = MultiAddress.init(nodeAddr).valueOr:
|
||||
return err("failed to parse mix node address: " & $nodeAddr & ", error: " & error)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user