Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add closeWait to EthereumNode #635

Merged
merged 1 commit into from
Sep 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions eth/p2p.nim
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ logScope:
topics = "eth p2p"


proc addCapability*(node: var EthereumNode,
proc addCapability*(node: EthereumNode,
p: ProtocolInfo,
networkState: RootRef = nil) =
doAssert node.connectionState == ConnectionState.None
Expand All @@ -35,10 +35,10 @@ proc addCapability*(node: var EthereumNode,
if networkState.isNil.not:
node.protocolStates[p.index] = networkState

template addCapability*(node: var EthereumNode, Protocol: type) =
template addCapability*(node: EthereumNode, Protocol: type) =
addCapability(node, Protocol.protocolInfo)

template addCapability*(node: var EthereumNode,
template addCapability*(node: EthereumNode,
Protocol: type,
networkState: untyped) =
mixin NetworkState
Expand All @@ -53,12 +53,12 @@ template addCapability*(node: var EthereumNode,
addCapability(node, Protocol.protocolInfo,
cast[RootRef](networkState))

proc replaceNetworkState*(node: var EthereumNode,
proc replaceNetworkState*(node: EthereumNode,
p: ProtocolInfo,
networkState: RootRef) =
node.protocolStates[p.index] = networkState

template replaceNetworkState*(node: var EthereumNode,
template replaceNetworkState*(node: EthereumNode,
Protocol: type,
networkState: untyped) =
mixin NetworkState
Expand Down Expand Up @@ -237,3 +237,7 @@ func hasPeer*(node: EthereumNode, n: Node): bool =

func hasPeer*(node: EthereumNode, n: Peer): bool =
n in node.peerPool

proc closeWait*(node: EthereumNode) {.async.} =
node.stopListening()
await node.listeningServer.closeWait()
Loading