Use attribute for static final genesis premine amount

This commit is contained in:
nicksavers 2014-10-03 14:32:53 +02:00
parent 72823df2f2
commit 9ec7e20191
2 changed files with 4 additions and 6 deletions

View File

@ -29,6 +29,8 @@ import java.math.BigInteger;
*/ */
public class Genesis extends Block { public class Genesis extends Block {
public final static BigInteger PREMINE_AMOUNT = BigInteger.valueOf(2).pow(200);
private static String[] premine = new String[] { private static String[] premine = new String[] {
"51ba59315b3a95761d0863b05ccc7a7f54703d99", "51ba59315b3a95761d0863b05ccc7a7f54703d99",
"e4157b34ea9615cfbde6b4fda419828124b70c78", // # (CH) "e4157b34ea9615cfbde6b4fda419828124b70c78", // # (CH)
@ -70,7 +72,7 @@ public class Genesis extends Block {
// some value stateRoot. The latest documentation should be consulted for the value of the state root. // some value stateRoot. The latest documentation should be consulted for the value of the state root.
for (String address : premine) { for (String address : premine) {
AccountState acctState = new AccountState(); AccountState acctState = new AccountState();
acctState.addToBalance(getPremineAmount()); acctState.addToBalance(PREMINE_AMOUNT);
state.update(Hex.decode(address), acctState.getEncoded()); state.update(Hex.decode(address), acctState.getEncoded());
} }
setStateRoot(state.getRootHash()); setStateRoot(state.getRootHash());
@ -89,8 +91,4 @@ public class Genesis extends Block {
public final static String[] getPremine() { public final static String[] getPremine() {
return premine; return premine;
} }
public final static BigInteger getPremineAmount() {
return BigInteger.valueOf(2).pow(200);
}
} }

View File

@ -136,7 +136,7 @@ public class RepositoryImpl implements Repository {
logger.info("DB is empty - adding Genesis"); logger.info("DB is empty - adding Genesis");
for (String address : Genesis.getPremine()) { for (String address : Genesis.getPremine()) {
this.createAccount(Hex.decode(address)); this.createAccount(Hex.decode(address));
this.addBalance (Hex.decode(address), Genesis.getPremineAmount()); this.addBalance (Hex.decode(address), Genesis.PREMINE_AMOUNT);
} }
blockchain.storeBlock(Genesis.getInstance()); blockchain.storeBlock(Genesis.getInstance());