fix: set peer info broadcasts to only self (#74)

This commit is contained in:
Cassandra Heart 2024-02-25 23:03:05 -06:00 committed by GitHub
parent 4fc58358a8
commit b90b88c6e3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 27 additions and 23 deletions

View File

@ -133,10 +133,6 @@ func (e *CeremonyDataClockConsensusEngine) handleCeremonyPeerListAnnounce(
return errors.Wrap(err, "handle ceremony peer list announce") return errors.Wrap(err, "handle ceremony peer list announce")
} }
e.peerAnnounceMapMx.Lock()
e.peerAnnounceMap[string(peerID)] = announce
e.peerAnnounceMapMx.Unlock()
for _, p := range announce.PeerList { for _, p := range announce.PeerList {
e.peerMapMx.Lock() e.peerMapMx.Lock()
if _, ok := e.uncooperativePeersMap[string(p.PeerId)]; ok { if _, ok := e.uncooperativePeersMap[string(p.PeerId)]; ok {

View File

@ -101,7 +101,6 @@ type CeremonyDataClockConsensusEngine struct {
peerMapMx sync.Mutex peerMapMx sync.Mutex
peerAnnounceMapMx sync.Mutex peerAnnounceMapMx sync.Mutex
lastKeyBundleAnnouncementFrame uint64 lastKeyBundleAnnouncementFrame uint64
peerAnnounceMap map[string]*protobufs.CeremonyPeerListAnnounce
peerMap map[string]*peerInfo peerMap map[string]*peerInfo
uncooperativePeersMap map[string]*peerInfo uncooperativePeersMap map[string]*peerInfo
} }
@ -227,7 +226,6 @@ func NewCeremonyDataClockConsensusEngine(
frameProverTrie: &tries.RollingFrecencyCritbitTrie{}, frameProverTrie: &tries.RollingFrecencyCritbitTrie{},
inclusionProver: inclusionProver, inclusionProver: inclusionProver,
syncingStatus: SyncStatusNotSyncing, syncingStatus: SyncStatusNotSyncing,
peerAnnounceMap: map[string]*protobufs.CeremonyPeerListAnnounce{},
peerMap: map[string]*peerInfo{}, peerMap: map[string]*peerInfo{},
uncooperativePeersMap: map[string]*peerInfo{}, uncooperativePeersMap: map[string]*peerInfo{},
minimumPeersRequired: minimumPeersRequired, minimumPeersRequired: minimumPeersRequired,
@ -330,20 +328,18 @@ func (e *CeremonyDataClockConsensusEngine) Start() <-chan error {
), ),
} }
deletes := []*peerInfo{} deletes := []*peerInfo{}
for _, v := range e.peerMap { list.PeerList = append(list.PeerList, &protobufs.CeremonyPeer{
list.PeerList = append(list.PeerList, &protobufs.CeremonyPeer{ PeerId: e.pubSub.GetPeerID(),
PeerId: v.peerId, Multiaddr: "",
Multiaddr: v.multiaddr, MaxFrame: frame.FrameNumber,
MaxFrame: v.maxFrame, Version: consensus.GetVersion(),
Timestamp: v.timestamp, Signature: sig,
Version: v.version, PublicKey: e.pubSub.GetPublicKey(),
Signature: v.signature, Timestamp: timestamp,
PublicKey: v.publicKey, TotalDistance: e.dataTimeReel.GetTotalDistance().FillBytes(
TotalDistance: e.dataTimeReel.GetTotalDistance().FillBytes( make([]byte, 256),
make([]byte, 256), ),
), })
})
}
for _, v := range e.uncooperativePeersMap { for _, v := range e.uncooperativePeersMap {
if v == nil { if v == nil {
continue continue
@ -359,12 +355,24 @@ func (e *CeremonyDataClockConsensusEngine) Start() <-chan error {
e.peerMapMx.Unlock() e.peerMapMx.Unlock()
if e.statsClient != nil { if e.statsClient != nil {
peerInfo := e.GetPeerInfo()
_, err := e.statsClient.PutPeerInfo( _, err := e.statsClient.PutPeerInfo(
context.Background(), context.Background(),
&protobufs.PutPeerInfoRequest{ &protobufs.PutPeerInfoRequest{
PeerInfo: peerInfo.PeerInfo, PeerInfo: []*protobufs.PeerInfo{
UncooperativePeerInfo: peerInfo.UncooperativePeerInfo, {
PeerId: e.pubSub.GetPeerID(),
Multiaddrs: []string{""},
MaxFrame: frame.FrameNumber,
Version: consensus.GetVersion(),
Signature: sig,
PublicKey: e.pubSub.GetPublicKey(),
Timestamp: timestamp,
TotalDistance: e.dataTimeReel.GetTotalDistance().FillBytes(
make([]byte, 256),
),
},
},
UncooperativePeerInfo: []*protobufs.PeerInfo{},
}, },
) )
if err != nil { if err != nil {