fix up merge
This commit is contained in:
parent
afb5cb88f9
commit
be0375f840
|
@ -10,3 +10,5 @@ build/
|
||||||
*.exe
|
*.exe
|
||||||
*.dll
|
*.dll
|
||||||
.vscode/
|
.vscode/
|
||||||
|
.DS_Store
|
||||||
|
tests/pubsub/testgossipsub
|
||||||
|
|
|
@ -319,14 +319,14 @@ proc newPubSub*[PubParams: object | bool](P: typedesc[PubSub],
|
||||||
verifySignature: verifySignature,
|
verifySignature: verifySignature,
|
||||||
sign: sign,
|
sign: sign,
|
||||||
cleanupLock: newAsyncLock(),
|
cleanupLock: newAsyncLock(),
|
||||||
msgIdProvider)
|
msgIdProvider: msgIdProvider)
|
||||||
else:
|
else:
|
||||||
result = P(peerInfo: peerInfo,
|
result = P(peerInfo: peerInfo,
|
||||||
triggerSelf: triggerSelf,
|
triggerSelf: triggerSelf,
|
||||||
verifySignature: verifySignature,
|
verifySignature: verifySignature,
|
||||||
sign: sign,
|
sign: sign,
|
||||||
cleanupLock: newAsyncLock(),
|
cleanupLock: newAsyncLock(),
|
||||||
msgIdProvider,
|
msgIdProvider: msgIdProvider,
|
||||||
parameters: params)
|
parameters: params)
|
||||||
result.initPubSub()
|
result.initPubSub()
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,6 @@ proc newStandardSwitch*(privKey = none(PrivateKey),
|
||||||
address = MultiAddress.init("/ip4/127.0.0.1/tcp/0").tryGet(),
|
address = MultiAddress.init("/ip4/127.0.0.1/tcp/0").tryGet(),
|
||||||
triggerSelf = false,
|
triggerSelf = false,
|
||||||
gossip = false,
|
gossip = false,
|
||||||
gossipParams = GossipSubParams.init(),
|
|
||||||
secureManagers: openarray[SecureProtocol] = [
|
secureManagers: openarray[SecureProtocol] = [
|
||||||
# array cos order matters
|
# array cos order matters
|
||||||
SecureProtocol.Secio,
|
SecureProtocol.Secio,
|
||||||
|
@ -64,8 +63,7 @@ proc newStandardSwitch*(privKey = none(PrivateKey),
|
||||||
triggerSelf = triggerSelf,
|
triggerSelf = triggerSelf,
|
||||||
verifySignature = verifySignature,
|
verifySignature = verifySignature,
|
||||||
sign = sign,
|
sign = sign,
|
||||||
msgIdProvider = msgIdProvider,
|
msgIdProvider = msgIdProvider).PubSub
|
||||||
gossipParams).PubSub
|
|
||||||
else:
|
else:
|
||||||
newPubSub(FloodSub,
|
newPubSub(FloodSub,
|
||||||
peerInfo = peerInfo,
|
peerInfo = peerInfo,
|
||||||
|
|
|
@ -555,8 +555,8 @@ proc stop*(s: Switch) {.async.} =
|
||||||
proc maintainPeer(s: Switch, peerInfo: PeerInfo) {.async.} =
|
proc maintainPeer(s: Switch, peerInfo: PeerInfo) {.async.} =
|
||||||
while s.running:
|
while s.running:
|
||||||
tryAndWarn "explicit peer maintain":
|
tryAndWarn "explicit peer maintain":
|
||||||
var conn = s.connections.getOrDefault(peerInfo.id)
|
var conns = s.connections.getOrDefault(peerInfo.id)
|
||||||
if conn.isNil or conn.closed:
|
if conns.len == 0:
|
||||||
# attempt re-connect in this case
|
# attempt re-connect in this case
|
||||||
trace "explicit peering, trying to re-connect", peer=peerInfo
|
trace "explicit peering, trying to re-connect", peer=peerInfo
|
||||||
await s.connect(peerInfo)
|
await s.connect(peerInfo)
|
||||||
|
@ -587,13 +587,13 @@ proc subscribeToPeer*(s: Switch, peerInfo: PeerInfo) {.async, gcsafe.} =
|
||||||
|
|
||||||
s.dialedPubSubPeers.incl(peerInfo.id)
|
s.dialedPubSubPeers.incl(peerInfo.id)
|
||||||
try:
|
try:
|
||||||
if (await s.ms.select(conn, s.pubSub.get().codec)):
|
if (await s.ms.select(stream, s.pubSub.get().codec)):
|
||||||
await s.pubSub.get().subscribeToPeer(conn)
|
await s.pubSub.get().subscribeToPeer(stream)
|
||||||
else:
|
else:
|
||||||
await conn.close()
|
await stream.close()
|
||||||
except CatchableError as exc:
|
except CatchableError as exc:
|
||||||
trace "exception in subscribe to peer", peer = peerInfo.shortLog, exc = exc.msg
|
trace "exception in subscribe to peer", peer = peerInfo.shortLog, exc = exc.msg
|
||||||
await conn.close()
|
await stream.close()
|
||||||
finally:
|
finally:
|
||||||
s.dialedPubSubPeers.excl(peerInfo.id)
|
s.dialedPubSubPeers.excl(peerInfo.id)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue