• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java FilteredBlock类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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();
    }
}
 
开发者ID:lvaccaro,项目名称:BitcoinBlockExplorer,代码行数:18,代码来源:FragmentBlocks.java


示例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;
            }

        }
    }
}
 
开发者ID:ehanoc,项目名称:xwallet,代码行数:21,代码来源:DownloadProgressListener.java


示例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();
		}
	}
}
 
开发者ID:kit-tm,项目名称:bitnym,代码行数:27,代码来源:MixPartnerDiscovery.java


示例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();
    }
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:23,代码来源:Wallet.java


示例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;
    }
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:21,代码来源:DownloadProgressTracker.java


示例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);
        }
    }
}
 
开发者ID:ehanoc,项目名称:xwallet,代码行数:19,代码来源:BitcoinRecoverAction.java


示例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);
        }
    }
}
 
开发者ID:ehanoc,项目名称:xwallet,代码行数:19,代码来源:BitcoinSetupAction.java


示例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);
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:12,代码来源:BlockchainServiceImpl.java


示例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) {
  }
  */
}
 
开发者ID:ppkpub,项目名称:javatool,代码行数:13,代码来源:PPkPeerEventListener.java


示例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);
}
 
开发者ID:soapboxsys,项目名称:ombuds-android,代码行数:13,代码来源:BlockchainServiceImpl.java


示例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();
    }
}
 
开发者ID:RCasatta,项目名称:EternityWallAndroid,代码行数:15,代码来源:MyDownloadListener.java


示例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());
}
 
开发者ID:lvaccaro,项目名称:BitcoinBlockExplorer,代码行数:6,代码来源:Bitcoin.java


示例13: onBlocksDownloaded

import org.bitcoinj.core.FilteredBlock; //导入依赖的package包/类
@Override
public void onBlocksDownloaded(Peer peer, Block block, @Nullable FilteredBlock filteredBlock, int blocksLeft) {
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:4,代码来源:AbstractPeerEventListener.java


示例14: onBlocksDownloadedEventListener

import org.bitcoinj.core.FilteredBlock; //导入依赖的package包/类
protected void onBlocksDownloadedEventListener(Peer peer, Block block, FilteredBlock filteredBlock, int blocksLeft) {
    this.blocksLeft.set(blocksLeft);
}
 
开发者ID:rnicoll,项目名称:cate,代码行数:4,代码来源:Network.java


示例15: onBlocksDownloaded

import org.bitcoinj.core.FilteredBlock; //导入依赖的package包/类
@Override
public void onBlocksDownloaded(Peer peer, Block block, FilteredBlock fblock, int blocksLeft)
{
    importer.saveBlock(block);

}
 
开发者ID:fireduck64,项目名称:jelectrum,代码行数:7,代码来源:ImportEventListener.java



注:本文中的org.bitcoinj.core.FilteredBlock类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java NodeFencer类代码示例发布时间:2022-05-22
下一篇:
Java LauncherActivityInfo类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap