diff --git a/ethereumj-core/src/main/java/org/ethereum/core/BlockchainImpl.java b/ethereumj-core/src/main/java/org/ethereum/core/BlockchainImpl.java index 40b14563..4ac945a7 100644 --- a/ethereumj-core/src/main/java/org/ethereum/core/BlockchainImpl.java +++ b/ethereumj-core/src/main/java/org/ethereum/core/BlockchainImpl.java @@ -132,7 +132,7 @@ public class BlockchainImpl implements Blockchain { ethereumListener.onBlock(block); } - private void processBlock(Block block) { + private void processBlock(Block block) { if(block.isValid()) { if (!block.isGenesis()) { if (!CONFIG.blockChainOnly()) { @@ -300,7 +300,9 @@ public class BlockchainImpl implements Blockchain { } // GET TOTAL ETHER VALUE AVAILABLE FOR TX FEE - BigInteger gasDebit = tx.getTotalGasValueDebit(); + // TODO: performance improve multiply without BigInteger + BigInteger gasPrice = new BigInteger(1, tx.getGasPrice()); + BigInteger gasDebit = new BigInteger(1, tx.getGasLimit()).multiply(gasPrice); // Debit the actual total gas value from the sender // the purchased gas will be available for @@ -357,7 +359,7 @@ public class BlockchainImpl implements Blockchain { if (CONFIG.playVM()) vm.play(program); ProgramResult result = program.getResult(); - applyProgramResult(result, gasDebit, trackRepository, + applyProgramResult(result, gasDebit, gasPrice, trackRepository, senderAddress, receiverAddress, coinbase, isContractCreation); gasUsed = result.getGasUsed(); @@ -371,7 +373,6 @@ public class BlockchainImpl implements Blockchain { long dataCost = tx.getData() == null ? 0: tx.getData().length * GasCost.TXDATA; gasUsed = GasCost.TRANSACTION + dataCost; - BigInteger gasPrice = new BigInteger(1, tx.getGasPrice()); BigInteger refund = gasDebit.subtract(BigInteger.valueOf(gasUsed).multiply(gasPrice)); if (refund.signum() > 0) { repository.addBalance(senderAddress, refund); @@ -391,7 +392,7 @@ public class BlockchainImpl implements Blockchain { * @param contractAddress */ private void applyProgramResult(ProgramResult result, BigInteger gasDebit, - Repository repository, byte[] senderAddress, + BigInteger gasPrice, Repository repository, byte[] senderAddress, byte[] contractAddress, byte[] coinbase, boolean initResults) { if (result.getException() != null @@ -401,7 +402,6 @@ public class BlockchainImpl implements Blockchain { throw result.getException(); } - BigInteger gasPrice = BigInteger.valueOf(this.getGasPrice()); BigInteger refund = gasDebit.subtract(BigInteger.valueOf( result.getGasUsed()).multiply(gasPrice)); diff --git a/ethereumj-core/src/main/java/org/ethereum/core/Transaction.java b/ethereumj-core/src/main/java/org/ethereum/core/Transaction.java index c1730a0e..3184686a 100644 --- a/ethereumj-core/src/main/java/org/ethereum/core/Transaction.java +++ b/ethereumj-core/src/main/java/org/ethereum/core/Transaction.java @@ -14,7 +14,6 @@ import org.spongycastle.util.BigIntegers; import java.math.BigInteger; import java.security.SignatureException; -import java.util.Arrays; /** * A transaction (formally, T) is a single cryptographically @@ -153,11 +152,6 @@ public class Transaction { return gasLimit; } - // TODO: performance improve multiply without BigInteger - public BigInteger getTotalGasValueDebit() { - return new BigInteger(1, gasLimit).multiply(new BigInteger(1, gasPrice)); - } - public byte[] getData() { if (!parsed) rlpParse(); return data;