3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-01-31 23:32:16 +00:00

DownloadListener: don't print redundant noise after catching up with the chain.

This commit is contained in:
Mike Hearn 2013-04-12 15:28:46 +02:00
parent dd4d237cd9
commit 30eb1f8043

View File

@ -29,6 +29,7 @@ public class DownloadListener extends AbstractPeerEventListener {
private int originalBlocksLeft = -1; private int originalBlocksLeft = -1;
private int lastPercent = 0; private int lastPercent = 0;
private Semaphore done = new Semaphore(0); private Semaphore done = new Semaphore(0);
private boolean caughtUp = false;
@Override @Override
public void onChainDownloadStarted(Peer peer, int blocksLeft) { public void onChainDownloadStarted(Peer peer, int blocksLeft) {
@ -42,7 +43,11 @@ public class DownloadListener extends AbstractPeerEventListener {
@Override @Override
public void onBlocksDownloaded(Peer peer, Block block, int blocksLeft) { public void onBlocksDownloaded(Peer peer, Block block, int blocksLeft) {
if (caughtUp)
return;
if (blocksLeft == 0) { if (blocksLeft == 0) {
caughtUp = true;
doneDownload(); doneDownload();
done.release(); done.release();
} }
@ -74,15 +79,15 @@ public class DownloadListener extends AbstractPeerEventListener {
* @param blocks the number of blocks to download, estimated * @param blocks the number of blocks to download, estimated
*/ */
protected void startDownload(int blocks) { protected void startDownload(int blocks) {
System.out.println("Downloading block chain of size " + blocks + ". " + if (blocks > 0)
(blocks > 1000 ? "This may take a while." : "")); System.out.println("Downloading block chain of size " + blocks + ". " +
(blocks > 1000 ? "This may take a while." : ""));
} }
/** /**
* Called when we are done downloading the block chain. * Called when we are done downloading the block chain.
*/ */
protected void doneDownload() { protected void doneDownload() {
System.out.println("Done downloading block chain");
} }
/** /**