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