本文整理汇总了Java中org.ethereum.core.Blockchain.getBlockStore方法的典型用法代码示例。如果您正苦于以下问题:Java Blockchain.getBlockStore方法的具体用法?Java Blockchain.getBlockStore怎么用?Java Blockchain.getBlockStore使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.ethereum.core.Blockchain
的用法示例。
在下文中一共展示了Blockchain.getBlockStore方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resetSnapshots
import org.ethereum.core.Blockchain; //导入方法依赖的package包/类
public boolean resetSnapshots(Blockchain blockchain) {
this.snapshots = new ArrayList<>();
PendingState pendingState = blockchain.getPendingState();
long bestNumber = blockchain.getBestBlock().getNumber();
BlockStore store = blockchain.getBlockStore();
Block block = store.getChainBlockByNumber(0);
BigInteger difficulty = blockchain.getBlockStore().getTotalDifficultyForHash(block.getHash());
blockchain.setStatus(block, difficulty);
// To clean pending state, first process the fork
blockchain.getPendingState().processBest(block);
// then, clear any reverted transaction
pendingState.clearPendingState(pendingState.getAllPendingTransactions());
pendingState.clearWire(pendingState.getWireTransactions());
// Remove removed blocks from store
for (long nb = blockchain.getBestBlock().getNumber() + 1; nb <= bestNumber; nb++) {
blockchain.removeBlocksByNumber(nb);
}
return true;
}
示例2: revertToSnapshot
import org.ethereum.core.Blockchain; //导入方法依赖的package包/类
public boolean revertToSnapshot(Blockchain blockchain, int snapshotId) {
if (snapshotId <= 0 || snapshotId > this.snapshots.size()) {
return false;
}
long newBestBlockNumber = this.snapshots.get(snapshotId - 1).longValue();
List<Long> newSnapshots = this.snapshots.stream().limit(snapshotId).collect(Collectors.toList());
this.snapshots = newSnapshots;
PendingState pendingState = blockchain.getPendingState();
long currentBestBlockNumber = blockchain.getBestBlock().getNumber();
if (newBestBlockNumber >= currentBestBlockNumber) {
return true;
}
BlockStore store = blockchain.getBlockStore();
Block block = store.getChainBlockByNumber(newBestBlockNumber);
BigInteger difficulty = blockchain.getBlockStore().getTotalDifficultyForHash(block.getHash());
blockchain.setStatus(block, difficulty);
// To clean pending state, first process the fork
blockchain.getPendingState().processBest(block);
// then, clear any reverted transaction
pendingState.clearPendingState(pendingState.getAllPendingTransactions());
pendingState.clearWire(pendingState.getWireTransactions());
// Remove removed blocks from store
for (long nb = blockchain.getBestBlock().getNumber() + 1; nb <= currentBestBlockNumber; nb++) {
blockchain.removeBlocksByNumber(nb);
}
return true;
}
示例3: getMinerServer
import org.ethereum.core.Blockchain; //导入方法依赖的package包/类
private static MinerServerImpl getMinerServer(Blockchain blockchain) {
SimpleEthereum ethereum = new SimpleEthereum();
SimpleWorldManager worldManager = new SimpleWorldManager();
worldManager.setBlockchain(blockchain);
ethereum.repository = (org.ethereum.facade.Repository)blockchain.getRepository();
ethereum.worldManager = worldManager;
DifficultyCalculator difficultyCalculator = new DifficultyCalculator(ConfigHelper.CONFIG);
return new MinerServerImpl(ConfigHelper.CONFIG, ethereum, blockchain, blockchain.getBlockStore(), blockchain.getPendingState(),
blockchain.getRepository(), ConfigUtils.getDefaultMiningConfig(),
new BlockValidationRuleDummy(), worldManager.getNodeBlockProcessor(),
difficultyCalculator, new GasLimitCalculator(ConfigHelper.CONFIG),
new ProofOfWorkRule(ConfigHelper.CONFIG).setFallbackMiningEnabled(false));
}