mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-01-11 21:04:11 +00:00
fix addKnownToPeer in wire protocol handler
This commit is contained in:
parent
35e4607f87
commit
eb701fd3d7
@ -172,8 +172,11 @@ proc cleanupKnownByPeer(ctx: EthWireRef) =
|
||||
|
||||
proc addToKnownByPeer(ctx: EthWireRef, txHashes: openArray[Hash256], peer: Peer) =
|
||||
var map: HashToTime
|
||||
if not ctx.knownByPeer.take(peer, map):
|
||||
ctx.knownByPeer.withValue(peer, val) do:
|
||||
map = val[]
|
||||
do:
|
||||
map = newTable[Hash256, Time]()
|
||||
ctx.knownByPeer[peer] = map
|
||||
|
||||
for txHash in txHashes:
|
||||
if txHash notin map:
|
||||
@ -184,8 +187,11 @@ proc addToKnownByPeer(ctx: EthWireRef,
|
||||
peer: Peer,
|
||||
newHashes: var seq[Hash256]) =
|
||||
var map: HashToTime
|
||||
if not ctx.knownByPeer.take(peer, map):
|
||||
ctx.knownByPeer.withValue(peer, val) do:
|
||||
map = val[]
|
||||
do:
|
||||
map = newTable[Hash256, Time]()
|
||||
ctx.knownByPeer[peer] = map
|
||||
|
||||
newHashes = newSeqOfCap[Hash256](txHashes.len)
|
||||
for txHash in txHashes:
|
||||
|
@ -117,12 +117,15 @@ proc cleanupKnownByPeer(ctx: LegacySyncRef) =
|
||||
proc addToKnownByPeer(ctx: LegacySyncRef,
|
||||
blockHash: Hash256,
|
||||
peer: Peer): bool =
|
||||
|
||||
var map: HashToTime
|
||||
if not ctx.knownByPeer.take(peer, map):
|
||||
map = newTable[Hash256, Time]()
|
||||
result = false
|
||||
else:
|
||||
ctx.knownByPeer.withValue(peer, val) do:
|
||||
map = val[]
|
||||
result = true
|
||||
do:
|
||||
map = newTable[Hash256, Time]()
|
||||
ctx.knownByPeer[peer] = map
|
||||
result = false
|
||||
|
||||
map[blockHash] = getTime()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user