Skip to content

Commit

Permalink
cleaner solution for sharing the queue
Browse files Browse the repository at this point in the history
  • Loading branch information
kdeme authored and zah committed Nov 21, 2019
1 parent f02f358 commit bc2b76f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 5 additions & 5 deletions eth/p2p/rlpx_protocols/waku_protocol.nim
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,8 @@ proc run(peer: Peer) {.gcsafe, async.}
proc run(node: EthereumNode, network: WakuNetwork) {.gcsafe, async.}

proc initProtocolState*(network: WakuNetwork, node: EthereumNode) {.gcsafe.} =
if node.protocolState(Whisper).isNil:
new(network.queue)
network.queue[] = initQueue(defaultQueueCapacity)
else:
network.queue = node.protocolState(Whisper).queue
new(network.queue)
network.queue[] = initQueue(defaultQueueCapacity)
network.filters = initTable[string, Filter]()
network.config.bloom = fullBloom()
network.config.powRequirement = defaultMinPow
Expand Down Expand Up @@ -466,3 +463,6 @@ proc resetMessageQueue*(node: EthereumNode) =
##
## NOTE: Not something that should be run in normal circumstances.
node.protocolState(Waku).queue[] = initQueue(defaultQueueCapacity)

proc shareMessageQueue*(node: EthereumNode) =
node.protocolState(Waku).queue = node.protocolState(Whisper).queue
2 changes: 2 additions & 0 deletions tests/p2p/test_waku_bridge.nim
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ suite "Waku - Whisper bridge tests":
nodeWakuWhisper.startListening()
let bridgeNode = newNode(initENode(nodeWakuWhisper.keys.pubKey,
nodeWakuWhisper.address))
nodeWakuWhisper.shareMessageQueue()

waitFor nodeWhisper.peerPool.connectToNode(bridgeNode)
waitFor nodeWaku.peerPool.connectToNode(bridgeNode)

Expand Down

0 comments on commit bc2b76f

Please sign in to comment.