From 1c5bbc3278e2bdf62bfbac64814b9a9912761a06 Mon Sep 17 00:00:00 2001 From: nicksavers Date: Fri, 11 Jul 2014 14:16:59 +0200 Subject: [PATCH] Calculate value of uncleReward only once --- ethereumj-core/src/main/java/org/ethereum/core/Block.java | 6 ++++-- .../src/main/java/org/ethereum/manager/WorldManager.java | 3 +-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/ethereumj-core/src/main/java/org/ethereum/core/Block.java b/ethereumj-core/src/main/java/org/ethereum/core/Block.java index ed09578d..0cfb9088 100644 --- a/ethereumj-core/src/main/java/org/ethereum/core/Block.java +++ b/ethereumj-core/src/main/java/org/ethereum/core/Block.java @@ -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++) { diff --git a/ethereumj-core/src/main/java/org/ethereum/manager/WorldManager.java b/ethereumj-core/src/main/java/org/ethereum/manager/WorldManager.java index d4d8ea85..3c05e5cc 100644 --- a/ethereumj-core/src/main/java/org/ethereum/manager/WorldManager.java +++ b/ethereumj-core/src/main/java/org/ethereum/manager/WorldManager.java @@ -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); } }