Skip to content

Commit

Permalink
implementing disconnectNode
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielmer committed Oct 11, 2024
1 parent 553d449 commit 32c1439
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ proc process*(
.join(",")
return ok(connectedPeers)
of DISCONNECT_PEER_BY_ID:
let peerId = PeerId.init($self[].peerId).valueOr:
error "DISCONNECT_PEER_BY_ID failed", error = $error
return err($error)
await waku.node.peerManager.disconnectNode(peerId)
return ok("")

return ok("")
5 changes: 4 additions & 1 deletion waku/node/peer_manager/peer_manager.nim
Original file line number Diff line number Diff line change
Expand Up @@ -381,9 +381,12 @@ proc connectToNodes*(
# later.
await sleepAsync(chronos.seconds(5))

proc disconnectNode*(pm: PeerManager, peerId: PeerId) {.async.} =
await pm.switch.disconnect(peerId)

proc disconnectNode*(pm: PeerManager, peer: RemotePeerInfo) {.async.} =
let peerId = peer.peerId
await pm.switch.disconnect(peerId)
await pm.disconnectNode(peerId)

# Dialing should be used for just protocols that require a stream to write and read
# This shall not be used to dial Relay protocols, since that would create
Expand Down

0 comments on commit 32c1439

Please sign in to comment.