本文整理汇总了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();
}
}
示例2: WorldManager
import org.ethereum.core.BlockchainImpl; //导入依赖的package包/类
private WorldManager() {
this.repository = new RepositoryImpl();
this.blockchain = new BlockchainImpl(repository);
this.peerDiscovery = new PeerDiscovery();
}
示例3: reset
import org.ethereum.core.BlockchainImpl; //导入依赖的package包/类
public void reset() {
this.repository = new RepositoryImpl();
this.blockchain = new BlockchainImpl(repository);
}