From 0e089d58999200e83ce3d0aa9a6af92131d25860 Mon Sep 17 00:00:00 2001 From: Cassandra Heart Date: Thu, 28 Mar 2024 00:24:44 -0500 Subject: [PATCH] fix: filter out peers that didn't pass the bandwidth/manifest test --- node/consensus/ceremony/consensus_frames.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/node/consensus/ceremony/consensus_frames.go b/node/consensus/ceremony/consensus_frames.go index 073143d..0f5fa24 100644 --- a/node/consensus/ceremony/consensus_frames.go +++ b/node/consensus/ceremony/consensus_frames.go @@ -170,6 +170,12 @@ func (e *CeremonyDataClockConsensusEngine) GetMostAheadPeer( if v.maxFrame > max && v.timestamp > config.GetMinimumVersionCutoff().UnixMilli() && bytes.Compare(v.version, config.GetMinimumVersion()) >= 0 && !ok { + manifest := e.peerInfoManager.GetPeerInfo(v.peerId) + if manifest == nil || manifest.Bandwidth == 0 { + e.logger.Debug("peer manifest not found or bandwidth zero") + continue + } + peer = v.peerId max = v.maxFrame } @@ -192,7 +198,7 @@ func (e *CeremonyDataClockConsensusEngine) sync( e.logger.Info("polling peer for new frames", zap.Binary("peer_id", peerId)) cc, err := e.pubSub.GetDirectChannel(peerId, "") if err != nil { - e.logger.Error( + e.logger.Debug( "could not establish direct channel", zap.Error(err), ) @@ -216,7 +222,7 @@ func (e *CeremonyDataClockConsensusEngine) sync( grpc.MaxCallRecvMsgSize(600*1024*1024), ) if err != nil { - e.logger.Error( + e.logger.Debug( "could not get frame", zap.Error(err), ) @@ -234,7 +240,7 @@ func (e *CeremonyDataClockConsensusEngine) sync( } if response == nil { - e.logger.Error("received no response from peer") + e.logger.Debug("received no response from peer") if err := cc.Close(); err != nil { e.logger.Error("error while closing connection", zap.Error(err)) }