mirror of
https://source.quilibrium.com/quilibrium/ceremonyclient.git
synced 2024-12-25 08:05:17 +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
|
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()
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user