Skip to content

Commit

Permalink
askForBlock method fix: don't request the block if there is already a…
Browse files Browse the repository at this point in the history
… pending request
  • Loading branch information
mably committed Jun 6, 2015
1 parent 2ec96a3 commit 274b5b2
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions ppc.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,9 +333,13 @@ func (b *blockManager) askForBlock(peer *peer, blockSha *wire.ShaHash) {
"existing inventory during block fetch: %v", err)
}
if !haveInv {
b.requestedBlocks[*blockSha] = struct{}{}
peer.requestedBlocks[*blockSha] = struct{}{}
peer.askFor(iv)
// Request the block if there is not already a pending request.
if _, exists := b.requestedBlocks[*blockSha]; !exists {
bmgrLog.Debugf("Requesting block %v from %s", blockSha, peer.addr)
b.requestedBlocks[*blockSha] = struct{}{}
peer.requestedBlocks[*blockSha] = struct{}{}
peer.askFor(iv)
}
}
}

Expand Down

0 comments on commit 274b5b2

Please sign in to comment.