mirror of
https://source.quilibrium.com/quilibrium/ceremonyclient.git
synced 2024-12-24 23:55:18 +00:00
tweak: adjust peer info behavior
This commit is contained in:
parent
f0e99b42dc
commit
2fe0f7180a
@ -170,41 +170,18 @@ func (e *CeremonyDataClockConsensusEngine) handleCeremonyPeerListAnnounce(
|
||||
}
|
||||
|
||||
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
|
||||
multiaddr = e.pubSub.GetMultiaddrOfPeer(peerID)
|
||||
}
|
||||
|
||||
pr, ok := e.peerMap[string(p.PeerId)]
|
||||
if !ok {
|
||||
e.peerMap[string(p.PeerId)] = &peerInfo{
|
||||
peerId: p.PeerId,
|
||||
multiaddr: multiaddr,
|
||||
maxFrame: p.MaxFrame,
|
||||
direct: bytes.Equal(p.PeerId, peerID),
|
||||
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.peerMap[string(p.PeerId)] = &peerInfo{
|
||||
peerId: p.PeerId,
|
||||
multiaddr: multiaddr,
|
||||
maxFrame: p.MaxFrame,
|
||||
direct: bytes.Equal(p.PeerId, peerID),
|
||||
lastSeen: time.Now().Unix(),
|
||||
timestamp: p.Timestamp,
|
||||
}
|
||||
}
|
||||
e.peerMapMx.Unlock()
|
||||
|
@ -22,7 +22,7 @@ import (
|
||||
"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
|
||||
|
||||
type InclusionMap = map[curves.PairingPoint]*protobufs.InclusionCommitment
|
||||
|
Loading…
Reference in New Issue
Block a user