bump libp2p (delayed send, without hooks) (#1413)

* use `switch.isConnected`

* libp2p

* add timeout to publish

* use isConnected

* adjust timeouts

* latest libp2p master

* do not drop peers
This commit is contained in:
Dmitriy Ryajov 2020-08-03 10:43:22 -06:00 committed by GitHub
parent 5b13d8f3fa
commit 52d9d269d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 7 deletions

View File

@ -826,7 +826,7 @@ proc runDiscoveryLoop*(node: Eth2Node) {.async.} =
if peerRecord.isOk: if peerRecord.isOk:
let peerInfo = peerRecord.value.toPeerInfo let peerInfo = peerRecord.value.toPeerInfo
if peerInfo != nil: if peerInfo != nil:
if peerInfo.id notin node.switch.connections: if not node.switch.isConnected(peerInfo):
await node.connQueue.addLast(peerInfo) await node.connQueue.addLast(peerInfo)
else: else:
peerInfo.close() peerInfo.close()
@ -855,8 +855,8 @@ proc init*(T: type Eth2Node, conf: BeaconNodeConf, enrForkId: ENRForkID,
result.switch = switch result.switch = switch
result.wantedPeers = conf.maxPeers result.wantedPeers = conf.maxPeers
result.peerPool = newPeerPool[Peer, PeerID](maxPeers = conf.maxPeers) result.peerPool = newPeerPool[Peer, PeerID](maxPeers = conf.maxPeers)
result.connectTimeout = 10.seconds result.connectTimeout = 1.minutes
result.seenThreshold = 10.minutes result.seenThreshold = 1.minutes
result.seenTable = initTable[PeerID, SeenItem]() result.seenTable = initTable[PeerID, SeenItem]()
result.connTable = initTable[PeerID, PeerInfo]() result.connTable = initTable[PeerID, PeerInfo]()
result.connQueue = newAsyncQueue[PeerInfo](ConcurrentConnections) result.connQueue = newAsyncQueue[PeerInfo](ConcurrentConnections)
@ -1243,7 +1243,7 @@ proc broadcast*(node: Eth2Node, topic: string, msg: auto) =
inc nbc_gossip_messages_sent inc nbc_gossip_messages_sent
let let
data = snappy.encode(SSZ.encode(msg)) data = snappy.encode(SSZ.encode(msg))
var futSnappy = node.switch.publish(topic & "_snappy", data) var futSnappy = node.switch.publish(topic & "_snappy", data, 1.minutes)
traceMessage(futSnappy, gossipId(data)) traceMessage(futSnappy, gossipId(data))
# TODO: # TODO:

View File

@ -570,7 +570,7 @@ proc discoveryLoop(conf: InspectorConf,
if pinfoOpt.isOk(): if pinfoOpt.isOk():
let pinfo = pinfoOpt.get() let pinfo = pinfoOpt.get()
if pinfo.hasTCP(): if pinfo.hasTCP():
if pinfo.id() notin switch.connections: if not switch.isConnected(pinfo):
debug "Discovered new peer", peer = pinfo, debug "Discovered new peer", peer = pinfo,
peers_count = len(peers) peers_count = len(peers)
await connQueue.addLast(pinfo) await connQueue.addLast(pinfo)

View File

@ -226,7 +226,8 @@ proc handleStatus(peer: Peer,
if not res: if not res:
debug "Peer is dead or already in pool", peer debug "Peer is dead or already in pool", peer
await peer.disconnect(ClientShutDown) # TODO: DON NOT DROP THE PEER!
# await peer.disconnect(ClientShutDown)
peer.setStatusMsg(theirStatus) peer.setStatusMsg(theirStatus)

2
vendor/nim-libp2p vendored

@ -1 +1 @@
Subproject commit 775cab414a68843c93c75e357f69cb1c04b32edd Subproject commit 980764774efe55f95412555d612bc1bee39396f3