当前位置: 首页>>代码示例>>Java>>正文


Java BlockchainImpl类代码示例

本文整理汇总了Java中org.ethereum.core.BlockchainImpl的典型用法代码示例。如果您正苦于以下问题:Java BlockchainImpl类的具体用法?Java BlockchainImpl怎么用?Java BlockchainImpl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


BlockchainImpl类属于org.ethereum.core包,在下文中一共展示了BlockchainImpl类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkBlocks

import org.ethereum.core.BlockchainImpl; //导入依赖的package包/类
public static void checkBlocks(Ethereum ethereum, AtomicInteger fatalErrors) {
    Block currentBlock = ethereum.getBlockchain().getBestBlock();
    int blockNumber = (int) currentBlock.getHeader().getNumber();

    try {
        BlockStore blockStore = ethereum.getBlockchain().getBlockStore();
        testLogger.info("Checking blocks from best block: {}", blockNumber);
        BigInteger curTotalDiff = blockStore.getTotalDifficultyForHash(currentBlock.getHash());

        while (blockNumber > 0) {
            currentBlock = ethereum.getBlockchain().getBlockByNumber(blockNumber);

            // Validate uncles
            assert ((BlockchainImpl) ethereum.getBlockchain()).validateUncles(currentBlock);
            // Validate total difficulty
            Assert.assertTrue(String.format("Total difficulty, count %s == %s blockStore",
                    curTotalDiff, blockStore.getTotalDifficultyForHash(currentBlock.getHash())),
                    curTotalDiff.compareTo(blockStore.getTotalDifficultyForHash(currentBlock.getHash())) == 0);
            curTotalDiff = curTotalDiff.subtract(currentBlock.getDifficultyBI());

            blockNumber--;
        }

        // Checking total difficulty for genesis
        currentBlock = ethereum.getBlockchain().getBlockByNumber(0);
        Assert.assertTrue(String.format("Total difficulty for genesis, count %s == %s blockStore",
                curTotalDiff, blockStore.getTotalDifficultyForHash(currentBlock.getHash())),
                curTotalDiff.compareTo(blockStore.getTotalDifficultyForHash(currentBlock.getHash())) == 0);
        Assert.assertTrue(String.format("Total difficulty, count %s == %s genesis",
                curTotalDiff, currentBlock.getDifficultyBI()),
                curTotalDiff.compareTo(currentBlock.getDifficultyBI()) == 0);

        testLogger.info("Checking blocks successful, ended on block: {}", blockNumber + 1);
    } catch (Exception | AssertionError ex) {
        testLogger.error(String.format("Block validation error on block #%s", blockNumber), ex);
        fatalErrors.incrementAndGet();
    }
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:39,代码来源:BlockchainValidation.java

示例2: WorldManager

import org.ethereum.core.BlockchainImpl; //导入依赖的package包/类
private WorldManager() {
	this.repository = new RepositoryImpl();
	this.blockchain = new BlockchainImpl(repository);
       this.peerDiscovery = new PeerDiscovery();
}
 
开发者ID:ethereumj,项目名称:ethereumj,代码行数:6,代码来源:WorldManager.java

示例3: reset

import org.ethereum.core.BlockchainImpl; //导入依赖的package包/类
public void reset() {
    this.repository = new RepositoryImpl();
    this.blockchain = new BlockchainImpl(repository);
}
 
开发者ID:ethereumj,项目名称:ethereumj,代码行数:5,代码来源:WorldManager.java


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