mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2024-11-20 10:12:19 +01:00
Do not callback if nothing to download from peer. Resolves issue 61
This commit is contained in:
parent
dfad026523
commit
3327e02f80
@ -366,13 +366,15 @@ public class Peer {
|
||||
* downloaded the same number of blocks that the peer advertised having in its version handshake message.
|
||||
*/
|
||||
public void startBlockChainDownload() throws IOException {
|
||||
for (PeerEventListener listener : eventListeners) {
|
||||
synchronized (listener) {
|
||||
listener.onChainDownloadStarted(this, getPeerBlocksToGet());
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: peer might still have blocks that we don't have, and even have a heavier
|
||||
// chain even if the chain block count is lower.
|
||||
if (getPeerBlocksToGet() > 0) {
|
||||
for (PeerEventListener listener : eventListeners) {
|
||||
synchronized (listener) {
|
||||
listener.onChainDownloadStarted(this, getPeerBlocksToGet());
|
||||
}
|
||||
}
|
||||
|
||||
// When we just want as many blocks as possible, we can set the target hash to zero.
|
||||
blockChainDownload(Sha256Hash.ZERO_HASH);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user