increase default max peers (#2106)
* increase default max peers also avoid reconnection when opening stream as this might induce a loop * Use dial without addresses * dial back max peers a little
This commit is contained in:
parent
b32c7c0851
commit
c3bfe15a35
|
@ -139,7 +139,7 @@ type
|
||||||
name: "udp-port" }: Port
|
name: "udp-port" }: Port
|
||||||
|
|
||||||
maxPeers* {.
|
maxPeers* {.
|
||||||
defaultValue: 79 # The Wall gets released
|
defaultValue: 160 # 5 (fanout) * 64 (subnets) / 2 (subs) for a heathy mesh
|
||||||
desc: "The maximum number of peers to connect to"
|
desc: "The maximum number of peers to connect to"
|
||||||
name: "max-peers" }: int
|
name: "max-peers" }: int
|
||||||
|
|
||||||
|
|
|
@ -311,10 +311,13 @@ template remote*(peer: Peer): untyped =
|
||||||
proc openStream(node: Eth2Node,
|
proc openStream(node: Eth2Node,
|
||||||
peer: Peer,
|
peer: Peer,
|
||||||
protocolId: string): Future[Connection] {.async.} =
|
protocolId: string): Future[Connection] {.async.} =
|
||||||
|
# When dialling here, we do not provide addresses - all new connection
|
||||||
|
# attempts are handled via `connect` which also takes into account
|
||||||
|
# reconnection timeouts
|
||||||
let
|
let
|
||||||
protocolId = protocolId & "ssz_snappy"
|
protocolId = protocolId & "ssz_snappy"
|
||||||
conn = await dial(
|
conn = await dial(
|
||||||
node.switch, peer.info.peerId, peer.info.addrs, protocolId)
|
node.switch, peer.info.peerId, protocolId)
|
||||||
|
|
||||||
# libp2p may replace peerinfo ref sometimes, so make sure we have a recent
|
# libp2p may replace peerinfo ref sometimes, so make sure we have a recent
|
||||||
# one
|
# one
|
||||||
|
@ -665,7 +668,7 @@ proc handleIncomingStream(network: Eth2Node,
|
||||||
case peer.connectionState
|
case peer.connectionState
|
||||||
of Disconnecting, Disconnected, None:
|
of Disconnecting, Disconnected, None:
|
||||||
# We got incoming stream request while disconnected or disconnecting.
|
# We got incoming stream request while disconnected or disconnecting.
|
||||||
warn "Got incoming request from disconnected peer", peer = peer,
|
debug "Got incoming request from disconnected peer", peer = peer,
|
||||||
message = msgName
|
message = msgName
|
||||||
await conn.closeWithEOF()
|
await conn.closeWithEOF()
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue