fixed lookup csc from peer
This commit is contained in:
parent
e163aa08c0
commit
3f56281351
|
@ -12,6 +12,7 @@ import chronos, chronicles
|
||||||
import
|
import
|
||||||
../spec/datatypes/[phase0, deneb],
|
../spec/datatypes/[phase0, deneb],
|
||||||
../spec/[forks, network, eip7594_helpers],
|
../spec/[forks, network, eip7594_helpers],
|
||||||
|
../spec/[eth2_ssz_serialization],
|
||||||
../networking/eth2_network,
|
../networking/eth2_network,
|
||||||
../consensus_object_pools/block_quarantine,
|
../consensus_object_pools/block_quarantine,
|
||||||
../consensus_object_pools/blob_quarantine,
|
../consensus_object_pools/blob_quarantine,
|
||||||
|
@ -268,8 +269,7 @@ proc fetchBlobsFromNetwork(self: RequestManager,
|
||||||
if not(isNil(peer)):
|
if not(isNil(peer)):
|
||||||
self.network.peerPool.release(peer)
|
self.network.peerPool.release(peer)
|
||||||
|
|
||||||
proc lookupCscFromPeer(peer: Peer):
|
proc lookupCscFromPeer(peer: Peer): uint64 =
|
||||||
uint64 =
|
|
||||||
# Fetches the custody column count from a remote peer
|
# Fetches the custody column count from a remote peer
|
||||||
# if the peer advertises their custody column count
|
# if the peer advertises their custody column count
|
||||||
# via the `csc` ENR field. If the peer does NOT, then
|
# via the `csc` ENR field. If the peer does NOT, then
|
||||||
|
@ -279,22 +279,24 @@ proc lookupCscFromPeer(peer: Peer):
|
||||||
if enrOpt.isNone:
|
if enrOpt.isNone:
|
||||||
debug "Could not get ENR from peer",
|
debug "Could not get ENR from peer",
|
||||||
peer_id = peer.peerId
|
peer_id = peer.peerId
|
||||||
return 0
|
return(peer.metadata.get.custody_subnet_count)
|
||||||
|
|
||||||
elif enrOpt.isOk:
|
else:
|
||||||
let
|
let
|
||||||
enr = enrOpt.get
|
enr = enrOpt.get
|
||||||
enrFieldOpt =
|
enrFieldOpt =
|
||||||
enr.get(enrCustodySubnetCountField, uint64)
|
enr.get(enrCustodySubnetCountField, seq[byte])
|
||||||
|
|
||||||
if not enrFieldOpt.isOk:
|
if enrFieldOpt.isOk:
|
||||||
debug "Issue with fetching `csc` field from ENR",
|
try:
|
||||||
enr = enr
|
let csc = SSZ.decode(enrFieldOpt.get(), CscBits)
|
||||||
else:
|
return csc.countOnes.uint64
|
||||||
return(enrFieldOpt.get)
|
except SszError as e:
|
||||||
|
debug "Could not decide the csc field in the ENR"
|
||||||
else:
|
return 0
|
||||||
return(peer.metadata.get.custody_subnet_count)
|
except SerializationError:
|
||||||
|
debug "Error in serializing the value"
|
||||||
|
return 0
|
||||||
|
|
||||||
proc constructValidCustodyPeers(rman: RequestManager,
|
proc constructValidCustodyPeers(rman: RequestManager,
|
||||||
peers: openArray[Peer]):
|
peers: openArray[Peer]):
|
||||||
|
|
Loading…
Reference in New Issue