use of org.aion.zero.impl.blockchain.AionHub.TransactionSortedSet in project aion by aionnetwork.
the class AionImpl method getNewMiningBlockTemplate.
// Returns a new template if a better parent block to mine on is found, or if the system time
// is ahead of the oldBlockTemplate
// Returns null if we're waiting on a Staking block, or if creating a new block template failed for some reason
@Override
public BlockContext getNewMiningBlockTemplate(BlockContext oldBlockTemplate, long systemTime) {
lock.lock();
try {
Block bestBlock = getBlockchain().getBestBlock();
if (getBlockchain().isUnityForkEnabledAtNextBlock() && bestBlock.getHeader().getSealType().equals(Seal.PROOF_OF_WORK)) {
return null;
} else {
BlockContext context;
byte[] bestBlockHash = bestBlock.getHash();
if (oldBlockTemplate == null || !Arrays.equals(bestBlockHash, oldBlockTemplate.block.getParentHash()) || (systemTime > oldBlockTemplate.block.getTimestamp() && getBlockchain().isUnityForkEnabledAtNextBlock())) {
TransactionSortedSet txSortSet = new TransactionSortedSet();
txSortSet.addAll(getAionHub().getPendingState().getPendingTransactions());
context = getBlockchain().createNewMiningBlockContext(bestBlock, new ArrayList<>(txSortSet), false);
} else {
context = oldBlockTemplate;
}
return context;
}
} finally {
lock.unlock();
}
}
Aggregations