本文整理汇总了Java中org.bitcoinj.core.FilteredBlock类的典型用法代码示例。如果您正苦于以下问题:Java FilteredBlock类的具体用法?Java FilteredBlock怎么用?Java FilteredBlock使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FilteredBlock类属于org.bitcoinj.core包,在下文中一共展示了FilteredBlock类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onBlocksDownloaded
import org.bitcoinj.core.FilteredBlock; //导入依赖的package包/类
@Override
public void onBlocksDownloaded(Peer peer, Block block, @Nullable FilteredBlock filteredBlock, int blocksLeft) {
//Log.d("BlocksDownloaded",block.getHashAsString());
Integer height=blockChain.getChainHead().getHeight();
synchronized (blocks) {
blocks.put(block, height);
if (blocks.keySet().size() >= 30) {
blocks.remove(blocks.keySet().toArray()[blocks.keySet().size() - 1]);
}
}
if(System.currentTimeMillis()-lastTimestamp>1000) {
refreshUI();
lastTimestamp = System.currentTimeMillis();
}
}
示例2: onBlocksDownloaded
import org.bitcoinj.core.FilteredBlock; //导入依赖的package包/类
public void onBlocksDownloaded(Peer peer, Block block, @Nullable FilteredBlock filteredBlock, int blocksLeft) {
if(!this.caughtUp) {
if(blocksLeft == 0) {
this.caughtUp = true;
this.doneDownload();
this.future.set(Long.valueOf(peer.getBestHeight()));
}
if(blocksLeft >= 0 && this.originalBlocksLeft > 0) {
double pct = 100.0D - 100.0D * ((double)blocksLeft / (double)this.originalBlocksLeft);
if((int)pct != this.lastPercent) {
this.lastBlockDate = new Date(block.getTimeSeconds() * 1000L);
this.progress(pct, blocksLeft, this.lastBlockDate);
this.lastPercent = (int)pct;
}
}
}
}
示例3: onBlocksDownloaded
import org.bitcoinj.core.FilteredBlock; //导入依赖的package包/类
@Override
public void onBlocksDownloaded(Peer arg0, Block arg1,
@Nullable FilteredBlock arg2, int arg3) {
System.out.println("received block");
boolean receivedBcastAnnouncmnt = false;
Map<Sha256Hash, Transaction> assocTxs = arg2.getAssociatedTransactions();
for(Transaction tx : assocTxs.values()) {
System.out.println("from within mixpartner discovery " + tx);
if(tx.getOutputs().size() > 1 &&
BroadcastAnnouncement.isBroadcastAnnouncementScript(tx.getOutput(1).getScriptBytes()))
//&& !wallet.isTransactionRelevant(tx)) {
//tx.getInput(0).getScriptSig().getChunks().get(0)
{
if(!this.broadcasts.contains(tx) && wallet.getTransaction(tx.getHash()) == null) {
this.broadcasts.add(tx);
receivedBcastAnnouncmnt = true;
}
}
}
if(receivedBcastAnnouncmnt) {
for(BroadcastAnnouncementChangeEventListener l : listeners) {
l.onBroadcastAnnouncementChanged();
}
}
}
示例4: checkForFilterExhaustion
import org.bitcoinj.core.FilteredBlock; //导入依赖的package包/类
/**
* Used by {@link Peer} to decide whether or not to discard this block and any blocks building upon it, in case
* the Bloom filter used to request them may be exhausted, that is, not have sufficient keys in the deterministic
* sequence within it to reliably find relevant transactions.
*/
public boolean checkForFilterExhaustion(FilteredBlock block) {
keyChainGroupLock.lock();
try {
int epoch = keyChainGroup.getCombinedKeyLookaheadEpochs();
for (Transaction tx : block.getAssociatedTransactions().values()) {
markKeysAsUsed(tx);
}
int newEpoch = keyChainGroup.getCombinedKeyLookaheadEpochs();
checkState(newEpoch >= epoch);
// If the key lookahead epoch has advanced, there was a call to addKeys and the PeerGroup already has a
// pending request to recalculate the filter queued up on another thread. The calling Peer should abandon
// block at this point and await a new filter before restarting the download.
return newEpoch > epoch;
} finally {
keyChainGroupLock.unlock();
}
}
示例5: onBlocksDownloaded
import org.bitcoinj.core.FilteredBlock; //导入依赖的package包/类
@Override
public void onBlocksDownloaded(Peer peer, Block block, @Nullable FilteredBlock filteredBlock, int blocksLeft) {
if (caughtUp)
return;
if (blocksLeft == 0) {
caughtUp = true;
doneDownload();
future.set(peer.getBestHeight());
}
if (blocksLeft < 0 || originalBlocksLeft <= 0)
return;
double pct = 100.0 - (100.0 * (blocksLeft / (double) originalBlocksLeft));
if ((int) pct != lastPercent) {
progress(pct, blocksLeft, new Date(block.getTimeSeconds() * 1000));
lastPercent = (int) pct;
}
}
示例6: onBlocksDownloaded
import org.bitcoinj.core.FilteredBlock; //导入依赖的package包/类
/**
*
* @param peer
* @param block
* @param filteredBlock
* @param blocksLeft
*/
@Override
public void onBlocksDownloaded(Peer peer, Block block, @Nullable FilteredBlock filteredBlock, int blocksLeft) {
super.onBlocksDownloaded(peer, block, filteredBlock, blocksLeft);
// to avoid overhead on notification, only 100th blocks or the last ones
if (blocksLeft % 100 == 0 || blocksLeft < 10) {
for (CoinActionCallback<CurrencyCoin> callback : _callbacks) {
callback.onBlocksDownloaded(_bitcoinManager.getCurrencyCoin(), this.lastPercent, blocksLeft, this.lastBlockDate);
}
}
}
示例7: onBlocksDownloaded
import org.bitcoinj.core.FilteredBlock; //导入依赖的package包/类
/**
*
* @param peer
* @param block
* @param filteredBlock
* @param blocksLeft
*/
@Override
public void onBlocksDownloaded(Peer peer, Block block, @Nullable FilteredBlock filteredBlock, int blocksLeft) {
super.onBlocksDownloaded(peer, block, filteredBlock, blocksLeft);
// to avoid overhead on notification, only 100th blocks or the last ones
if (blocksLeft % 100 == 0 || blocksLeft < 10) {
for (CoinActionCallback<CurrencyCoin> callback : _callbacks) {
callback.onBlocksDownloaded(_bitcoin, this.lastPercent, blocksLeft, this.lastBlockDate);
}
}
}
示例8: onBlocksDownloaded
import org.bitcoinj.core.FilteredBlock; //导入依赖的package包/类
@Override
public void onBlocksDownloaded(final Peer peer, final Block block, final FilteredBlock filteredBlock,
final int blocksLeft) {
delayHandler.removeCallbacksAndMessages(null);
final long now = System.currentTimeMillis();
if (now - lastMessageTime.get() > BLOCKCHAIN_STATE_BROADCAST_THROTTLE_MS)
delayHandler.post(runnable);
else
delayHandler.postDelayed(runnable, BLOCKCHAIN_STATE_BROADCAST_THROTTLE_MS);
}
示例9: onBlocksDownloaded
import org.bitcoinj.core.FilteredBlock; //导入依赖的package包/类
@Override
public void onBlocksDownloaded(Peer peer, Block block, FilteredBlock filteredBlock, int blocksLeft){
logger.info("Block downloaded: "+blocksLeft);
/*
//this doesn't work
Blocks blocks = Blocks.getInstance();
try {
blocks.importBlock(block, blocks.blockStore.get(block.getHash()).getHeight());
} catch (BlockStoreException e) {
}
*/
}
示例10: onBlocksDownloaded
import org.bitcoinj.core.FilteredBlock; //导入依赖的package包/类
@Override
public void onBlocksDownloaded(final Peer peer, final Block block, final FilteredBlock filteredBlock, final int blocksLeft)
{
delayHandler.removeCallbacksAndMessages(null);
final long now = System.currentTimeMillis();
if (now - lastMessageTime.get() > BLOCKCHAIN_STATE_BROADCAST_THROTTLE_MS)
delayHandler.post(runnable);
else
delayHandler.postDelayed(runnable, BLOCKCHAIN_STATE_BROADCAST_THROTTLE_MS);
}
示例11: onBlocksDownloaded
import org.bitcoinj.core.FilteredBlock; //导入依赖的package包/类
@Override
public void onBlocksDownloaded(Peer peer, Block block, FilteredBlock filteredBlock, int blocksLeft) {
super.onBlocksDownloaded(peer, block, filteredBlock, blocksLeft);
//Log.i(TAG, "onBlocksDownloaded");
size+=block.getMessageSize();
double pct = 100.0 - (100.0 * (blocksLeft / (double) originalBlocksLeft));
if ((int) pct != lastPercent) {
lastPercent = (int) pct;
walletObservable.setPercSync(lastPercent);
walletObservable.notifyObservers();
}
}
示例12: onBlocksDownloaded
import org.bitcoinj.core.FilteredBlock; //导入依赖的package包/类
@Override
public void onBlocksDownloaded(Peer peer, Block block, FilteredBlock filteredBlock, int blocksLeft) {
super.onBlocksDownloaded(peer, block, filteredBlock, blocksLeft);
//Log.i("onBlocksDownloaded", peer.toString());
}
示例13: onBlocksDownloaded
import org.bitcoinj.core.FilteredBlock; //导入依赖的package包/类
@Override
public void onBlocksDownloaded(Peer peer, Block block, @Nullable FilteredBlock filteredBlock, int blocksLeft) {
}
示例14: onBlocksDownloadedEventListener
import org.bitcoinj.core.FilteredBlock; //导入依赖的package包/类
protected void onBlocksDownloadedEventListener(Peer peer, Block block, FilteredBlock filteredBlock, int blocksLeft) {
this.blocksLeft.set(blocksLeft);
}
示例15: onBlocksDownloaded
import org.bitcoinj.core.FilteredBlock; //导入依赖的package包/类
@Override
public void onBlocksDownloaded(Peer peer, Block block, FilteredBlock fblock, int blocksLeft)
{
importer.saveBlock(block);
}