From dc974c18552079057b07b6185076d95d06aab66a Mon Sep 17 00:00:00 2001 From: Anca Zamfir Date: Mon, 20 May 2019 23:32:59 -0400 Subject: [PATCH] Remove pool's numPending --- blockchain/pool.go | 9 +-------- blockchain/pool_test.go | 1 - 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/blockchain/pool.go b/blockchain/pool.go index 42587313..fa9d3c4d 100644 --- a/blockchain/pool.go +++ b/blockchain/pool.go @@ -39,7 +39,6 @@ type blockPool struct { height int64 // height of next block to execute maxPeerHeight int64 // maximum height of all peers - numPending int32 // total numPending across peers TODO - can probably remove toBcR bcRMessageInterface } @@ -150,10 +149,7 @@ func (pool *blockPool) removePeer(peerID p2p.ID, err error) { // Reschedule the block requests made to the peer, or received and not processed yet. // Note that some of the requests may be removed further down. - for h, block := range pool.peers[peerID].blocks { - if block == nil { - pool.numPending-- - } + for h := range pool.peers[peerID].blocks { pool.rescheduleRequest(peerID, h) } @@ -261,8 +257,6 @@ func (pool *blockPool) sendRequest(height int64) bool { pool.logger.Info("assigned request to peer", "peer", peer.id, "height", height) pool.blocks[height] = peer.id - pool.numPending++ - peer.blocks[height] = nil peer.incrPending() @@ -293,7 +287,6 @@ func (pool *blockPool) addBlock(peerID p2p.ID, block *types.Block, blockSize int } peer.blocks[block.Height] = block - pool.numPending-- peer.decrPending(blockSize) pool.logger.Info("added new block", "height", block.Height, "from_peer", peerID, "total_pool_blocks", len(pool.blocks), "peer_numPending", peer.numPending) diff --git a/blockchain/pool_test.go b/blockchain/pool_test.go index 9615d093..a113cd86 100644 --- a/blockchain/pool_test.go +++ b/blockchain/pool_test.go @@ -326,7 +326,6 @@ func TestBlockPoolSendRequestBatch(t *testing.T) { var pool = tt.pool maxRequestsPerPeer = int32(tt.maxRequestsPerPeer) pool.makeNextRequests(10) - assert.Equal(t, tt.expNumPending, pool.numPending) assert.Equal(t, testResults.numRequestsSent, maxRequestsPerPeer*int32(len(pool.peers))) for _, tPeer := range tt.expPeerResults {