Calculate value of uncleReward only once

This commit is contained in:
nicksavers 2014-07-11 14:16:59 +02:00
parent 82c0d2ceab
commit 1c5bbc3278
2 changed files with 5 additions and 4 deletions

View File

@ -37,6 +37,8 @@ public class Block {
/* A scalar value equal to the mininum limit of gas expenditure per block */
private static long MIN_GAS_LIMIT = 125000L;
public static BigInteger BLOCK_REWARD = BigInteger.valueOf(1500000000000000000L);
public static BigInteger UNCLE_REWARD = BLOCK_REWARD.multiply(
BigInteger.valueOf(7)).divide(BigInteger.valueOf(8));
private BlockHeader header;
@ -91,7 +93,7 @@ public class Block {
// Parse Transactions
RLPList txReceipts = (RLPList) block.get(1);
this.processTxs(txReceipts);
this.parseTxs(txReceipts);
// Parse Uncles
RLPList uncleBlocks = (RLPList) block.get(2);
@ -259,7 +261,7 @@ public class Block {
return toStringBuff.toString();
}
private void processTxs(RLPList txReceipts) {
private void parseTxs(RLPList txReceipts) {
this.txsState = new Trie(null);
for (int i = 0; i < txReceipts.size(); i++) {

View File

@ -276,7 +276,6 @@ public class WorldManager {
}
}
private static BigInteger UNCLE_RATIO = BigInteger.valueOf(7).divide(BigInteger.valueOf(8));
public void applyBlock(Block block) {
int i = 0;
@ -293,7 +292,7 @@ public class WorldManager {
repository.createAccount(block.getCoinbase());
repository.addBalance(block.getCoinbase(), Block.BLOCK_REWARD);
for (Block uncle : block.getUncleList()) {
repository.addBalance(uncle.getCoinbase(), Block.BLOCK_REWARD.multiply(UNCLE_RATIO));
repository.addBalance(uncle.getCoinbase(), Block.UNCLE_REWARD);
}
}