use of org.hyperledger.besu.ethereum.retesteth.RetestethClock in project besu by hyperledger.
the class TestMineBlocks method mineNewBlock.
private boolean mineNewBlock() {
final RetestethClock retesethClock = context.getRetestethClock();
final ProtocolSchedule protocolSchedule = context.getProtocolSchedule();
final ProtocolContext protocolContext = context.getProtocolContext();
final MutableBlockchain blockchain = context.getBlockchain();
final HeaderValidationMode headerValidationMode = context.getHeaderValidationMode();
final PoWBlockCreator blockCreator = new PoWBlockCreator(context.getCoinbase(), () -> Optional.of(10_000_000L), header -> context.getExtraData(), context.getTransactionPool().getPendingTransactions(), protocolContext, protocolSchedule, context.getEthHashSolver(), Wei.ZERO, 0.0, blockchain.getChainHeadHeader());
final Block block = blockCreator.createBlock(retesethClock.instant().getEpochSecond());
// advance clock so next mine won't hit the same timestamp
retesethClock.advanceSeconds(1);
final BlockImporter blockImporter = protocolSchedule.getByBlockNumber(blockchain.getChainHeadBlockNumber()).getBlockImporter();
return blockImporter.importBlock(protocolContext, block, headerValidationMode, headerValidationMode);
}
Aggregations