From 2f4517f24025f2d60c6b1c3baa9adb01023dd078 Mon Sep 17 00:00:00 2001 From: Philip Su Date: Thu, 19 Oct 2023 14:02:57 -0700 Subject: [PATCH] use state to filter --- internal/blocksync/pool.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/blocksync/pool.go b/internal/blocksync/pool.go index 70c1d8699..b2d43b60d 100644 --- a/internal/blocksync/pool.go +++ b/internal/blocksync/pool.go @@ -438,10 +438,12 @@ func (pool *BlockPool) pickIncrAvailablePeer(height int64) *bpPeer { var goodPeers []types.NodeID // Remove peers with 0 score and shuffle list for _, peer := range sortedPeers { + if pool.peerManager.State(peer) == "ready,connected" { + goodPeers = append(goodPeers, peer) + } if pool.peerManager.Score(peer) == 0 { break } - goodPeers = append(goodPeers, peer) } rand.Seed(time.Now().UnixNano()) rand.Shuffle(len(goodPeers), func(i, j int) { goodPeers[i], goodPeers[j] = goodPeers[j], goodPeers[i] }) @@ -641,7 +643,6 @@ func (*bpRequester) OnStop() {} func (bpr *bpRequester) setBlock(block *types.Block, extCommit *types.ExtendedCommit, peerID types.NodeID) bool { bpr.mtx.Lock() if bpr.block != nil || bpr.peerID != peerID { - fmt.Printf("\nPSUDEBUG no match, existing block %v, want to set block %v peerId doesn't equal bprPeer %v, peer %v", bpr.block, block, bpr.peerID, peerID) bpr.mtx.Unlock() return false }