use of org.aion.vm.TransactionExecutor in project aion by aionnetwork.
the class AionBlockchainImpl method generatePreBlock.
/**
* For generating the necessary transactions for a block
*
* @param block
* @return
*/
private RetValidPreBlock generatePreBlock(IAionBlock block) {
long saveTime = System.nanoTime();
List<AionTxReceipt> receipts = new ArrayList<>();
List<AionTxExecSummary> summaries = new ArrayList<>();
List<AionTransaction> transactions = new ArrayList<>();
long energyRemaining = block.getNrgLimit();
for (AionTransaction tx : block.getTransactionsList()) {
TransactionExecutor executor = new TransactionExecutor(tx, block, track, false, energyRemaining);
AionTxExecSummary summary = executor.execute();
if (!summary.isRejected()) {
track.flush();
AionTxReceipt receipt = summary.getReceipt();
receipt.setPostTxState(repository.getRoot());
receipt.setTransaction(tx);
// otherwise, assuming we don't have timeouts, add the
// transaction
transactions.add(tx);
receipts.add(receipt);
summaries.add(summary);
energyRemaining -= receipt.getEnergyUsed();
}
}
Map<Address, BigInteger> rewards = addReward(block, summaries);
track.flush();
long totalTime = System.nanoTime() - saveTime;
chainStats.addBlockExecTime(totalTime);
return new RetValidPreBlock(transactions, rewards, receipts, summaries);
}
use of org.aion.vm.TransactionExecutor in project aion by aionnetwork.
the class AionBlockchainImpl method applyBlock.
private AionBlockSummary applyBlock(IAionBlock block) {
long saveTime = System.nanoTime();
List<AionTxReceipt> receipts = new ArrayList<>();
List<AionTxExecSummary> summaries = new ArrayList<>();
for (AionTransaction tx : block.getTransactionsList()) {
TransactionExecutor executor = new TransactionExecutor(tx, block, track);
AionTxExecSummary summary = executor.execute();
track.flush();
AionTxReceipt receipt = summary.getReceipt();
receipt.setPostTxState(repository.getRoot());
receipts.add(receipt);
summaries.add(summary);
}
Map<Address, BigInteger> rewards = addReward(block, summaries);
long totalTime = System.nanoTime() - saveTime;
chainStats.addBlockExecTime(totalTime);
return new AionBlockSummary(block, rewards, receipts, summaries);
}
use of org.aion.vm.TransactionExecutor in project aion by aionnetwork.
the class AionPendingStateImpl method executeTx.
private AionTxExecSummary executeTx(AionTransaction tx, boolean inPool) {
IAionBlock best = getBestBlock();
if (LOG.isTraceEnabled()) {
LOG.trace("executeTx: {}", Hex.toHexString(tx.getHash()));
}
TransactionExecutor executor = new TransactionExecutor(tx, best, pendingState);
if (inPool) {
executor.setBypassNonce(true);
}
return executor.execute();
}
Aggregations