|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.google.bitcoin.core.AbstractPeerEventListener
com.google.bitcoin.core.DownloadListener
public class DownloadListener
An implementation of AbstractPeerEventListener that listens to chain download events and tracks progress
as a percentage. The default implementation prints progress to stdout, but you can subclass it and override the
progress method to update a GUI instead.
| Constructor Summary | |
|---|---|
DownloadListener()
|
|
| Method Summary | |
|---|---|
void |
await()
Wait for the chain to be downloaded. |
protected void |
doneDownload()
Called when we are done downloading the block chain. |
void |
onBlocksDownloaded(Peer peer,
Block block,
int blocksLeft)
Called on a Peer thread when a block is received. |
void |
onChainDownloadStarted(Peer peer,
int blocksLeft)
Called when a download is started with the initial number of blocks to be downloaded. |
protected void |
progress(double pct,
int blocksSoFar,
Date date)
Called when download progress is made. |
protected void |
startDownload(int blocks)
Called when download is initiated. |
| Methods inherited from class com.google.bitcoin.core.AbstractPeerEventListener |
|---|
getData, onPeerConnected, onPeerDisconnected, onPreMessageReceived, onTransaction |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public DownloadListener()
| Method Detail |
|---|
public void onChainDownloadStarted(Peer peer,
int blocksLeft)
PeerEventListener
onChainDownloadStarted in interface PeerEventListeneronChainDownloadStarted in class AbstractPeerEventListenerpeer - the peer receiving the blockblocksLeft - the number of blocks left to download
public void onBlocksDownloaded(Peer peer,
Block block,
int blocksLeft)
PeerEventListenerThe block may have transactions or may be a header only once getheaders is implemented.
onBlocksDownloaded in interface PeerEventListeneronBlocksDownloaded in class AbstractPeerEventListenerpeer - the peer receiving the blockblock - the downloaded blockblocksLeft - the number of blocks left to download
protected void progress(double pct,
int blocksSoFar,
Date date)
pct - the percentage of chain downloaded, estimateddate - the date of the last block downloadedprotected void startDownload(int blocks)
blocks - the number of blocks to download, estimatedprotected void doneDownload()
public void await()
throws InterruptedException
InterruptedException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||