Remove pool's numPending

This commit is contained in:
Anca Zamfir 2019-05-20 23:32:59 -04:00
parent 0bfc3724f7
commit dc974c1855
No known key found for this signature in database
GPG Key ID: 61B09A558E4B6A7D
2 changed files with 1 additions and 9 deletions

View File

@ -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)

View File

@ -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 {