Fix Custody Columns (#14021)

This commit is contained in:
Nishant Das
2024-05-17 18:27:46 +03:00
committed by Manu NALEPA
parent d43139a5dc
commit 12e8c244b5
3 changed files with 11 additions and 2 deletions

View File

@@ -63,8 +63,7 @@ func (s *Service) CustodyCountFromRemotePeer(pid peer.ID) (uint64, error) {
if err := peerRecord.Load(&custodyObj); err != nil {
return 0, errors.Wrap(err, "load custody_subnet_count")
}
actualCustodyCount := ssz.UnmarshallUint64(custodyBytes)
actualCustodyCount := ssz.UnmarshallUint64(custodyObj)
if actualCustodyCount > peerCustodiedSubnetCount {
peerCustodiedSubnetCount = actualCustodyCount
}

View File

@@ -371,6 +371,8 @@ func (s *Service) filterPeer(node *enode.Node) bool {
// Ignore nodes that are already active.
if s.peers.IsActive(peerData.ID) {
// Constantly update enr for known peers
s.peers.UpdateENR(node.Record(), peerData.ID)
return false
}

View File

@@ -159,6 +159,14 @@ func (p *Status) Add(record *enr.Record, pid peer.ID, address ma.Multiaddr, dire
p.addIpToTracker(pid)
}
func (p *Status) UpdateENR(record *enr.Record, pid peer.ID) {
p.store.Lock()
defer p.store.Unlock()
if peerData, ok := p.store.PeerData(pid); ok {
peerData.Enr = record
}
}
// Address returns the multiaddress of the given remote peer.
// This will error if the peer does not exist.
func (p *Status) Address(pid peer.ID) (ma.Multiaddr, error) {