clean up triple lookup and avoid `KeyError` when adding muxer (#1057)
This commit is contained in:
parent
6c43ab3fce
commit
ca01ee06a8
|
@ -311,12 +311,14 @@ proc storeMuxer*(c: ConnManager,
|
||||||
|
|
||||||
raise newTooManyConnectionsError()
|
raise newTooManyConnectionsError()
|
||||||
|
|
||||||
assert muxer notin c.muxed.getOrDefault(peerId)
|
var newPeer = false
|
||||||
|
c.muxed.withValue(peerId, muxers):
|
||||||
let
|
doAssert muxers[].len > 0
|
||||||
newPeer = peerId notin c.muxed
|
doAssert muxer notin muxers[]
|
||||||
assert newPeer or c.muxed[peerId].len > 0
|
muxers[].add(muxer)
|
||||||
c.muxed.mgetOrPut(peerId, newSeq[Muxer]()).add(muxer)
|
do:
|
||||||
|
c.muxed[peerId] = @[muxer]
|
||||||
|
newPeer = true
|
||||||
libp2p_peers.set(c.muxed.len.int64)
|
libp2p_peers.set(c.muxed.len.int64)
|
||||||
|
|
||||||
asyncSpawn c.triggerConnEvent(
|
asyncSpawn c.triggerConnEvent(
|
||||||
|
|
Loading…
Reference in New Issue