tweak: adjust peer info behavior

This commit is contained in:
Cassandra Heart 2023-10-26 21:41:38 -05:00
parent f0e99b42dc
commit 2fe0f7180a
No known key found for this signature in database
GPG Key ID: 6352152859385958
2 changed files with 9 additions and 32 deletions

View File

@ -170,41 +170,18 @@ func (e *CeremonyDataClockConsensusEngine) handleCeremonyPeerListAnnounce(
} }
multiaddr := p.Multiaddr multiaddr := p.Multiaddr
if bytes.Equal(p.PeerId, peerID) { if bytes.Equal(p.PeerId, peerID) || p.Multiaddr == "" {
// we have to fetch self-reported peer info // we have to fetch self-reported peer info
multiaddr = e.pubSub.GetMultiaddrOfPeer(peerID) multiaddr = e.pubSub.GetMultiaddrOfPeer(peerID)
} }
pr, ok := e.peerMap[string(p.PeerId)] e.peerMap[string(p.PeerId)] = &peerInfo{
if !ok { peerId: p.PeerId,
e.peerMap[string(p.PeerId)] = &peerInfo{ multiaddr: multiaddr,
peerId: p.PeerId, maxFrame: p.MaxFrame,
multiaddr: multiaddr, direct: bytes.Equal(p.PeerId, peerID),
maxFrame: p.MaxFrame, lastSeen: time.Now().Unix(),
direct: bytes.Equal(p.PeerId, peerID), timestamp: p.Timestamp,
lastSeen: time.Now().Unix(),
timestamp: p.Timestamp,
}
} else {
if bytes.Equal(p.PeerId, peerID) {
e.peerMap[string(p.PeerId)] = &peerInfo{
peerId: p.PeerId,
multiaddr: multiaddr,
maxFrame: p.MaxFrame,
direct: true,
lastSeen: time.Now().Unix(),
timestamp: p.Timestamp,
}
} else if !pr.direct || time.Now().Unix()-pr.lastSeen > 30 {
e.peerMap[string(p.PeerId)] = &peerInfo{
peerId: p.PeerId,
multiaddr: p.Multiaddr,
maxFrame: p.MaxFrame,
direct: false,
lastSeen: time.Now().Unix(),
timestamp: p.Timestamp,
}
}
} }
} }
e.peerMapMx.Unlock() e.peerMapMx.Unlock()

View File

@ -22,7 +22,7 @@ import (
"source.quilibrium.com/quilibrium/monorepo/node/tries" "source.quilibrium.com/quilibrium/monorepo/node/tries"
) )
const PEER_INFO_TTL = 5 * 60 * 1000 const PEER_INFO_TTL = 60 * 60 * 1000
const UNCOOPERATIVE_PEER_INFO_TTL = 60 * 60 * 1000 const UNCOOPERATIVE_PEER_INFO_TTL = 60 * 60 * 1000
type InclusionMap = map[curves.PairingPoint]*protobufs.InclusionCommitment type InclusionMap = map[curves.PairingPoint]*protobufs.InclusionCommitment