Pass ReuseAddr flag for wakunode2 (#223)

This commit is contained in:
Kim De Mey 2020-10-14 05:32:37 +02:00 committed by GitHub
parent bef916b31c
commit cae31bd09b

View File

@ -59,6 +59,7 @@ proc init*(T: type WakuNode, nodeKey: crypto.PrivateKey,
## Status: Implemented. ## Status: Implemented.
## ##
let let
rng = crypto.newRng()
hostAddress = tcpEndPoint(bindIp, bindPort) hostAddress = tcpEndPoint(bindIp, bindPort)
announcedAddresses = if extIp.isNone() or extPort.isNone(): @[] announcedAddresses = if extIp.isNone() or extPort.isNone(): @[]
else: @[tcpEndPoint(extIp.get(), extPort.get())] else: @[tcpEndPoint(extIp.get(), extPort.get())]
@ -68,7 +69,8 @@ proc init*(T: type WakuNode, nodeKey: crypto.PrivateKey,
# XXX: Add this when we create node or start it? # XXX: Add this when we create node or start it?
peerInfo.addrs.add(hostAddress) peerInfo.addrs.add(hostAddress)
var switch = newStandardSwitch(some(nodekey), hostAddress) var switch = newStandardSwitch(some(nodekey), hostAddress,
transportFlags = {ServerFlags.ReuseAddr}, rng = rng)
# TODO Untested - verify behavior after switch interface change # TODO Untested - verify behavior after switch interface change
# More like this: # More like this:
# let pubsub = GossipSub.init( # let pubsub = GossipSub.init(
@ -88,7 +90,7 @@ proc init*(T: type WakuNode, nodeKey: crypto.PrivateKey,
result = WakuNode( result = WakuNode(
switch: switch, switch: switch,
rng: crypto.newRng(), rng: rng,
peerInfo: peerInfo, peerInfo: peerInfo,
wakuRelay: wakuRelay, wakuRelay: wakuRelay,
subscriptions: newTable[string, MessageNotificationSubscription](), subscriptions: newTable[string, MessageNotificationSubscription](),