cleaner solution for sharing the queue

This commit is contained in:
kdeme 2019-11-21 11:03:43 +01:00 committed by zah
parent f02f358bc3
commit bc2b76f09a
2 changed files with 7 additions and 5 deletions

View File

@ -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
@ -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

View File

@ -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)