Genesis calc fixed

This commit is contained in:
romanman 2014-06-25 10:10:54 +01:00
parent 1f2c70387f
commit f1ad918831
3 changed files with 10 additions and 9 deletions

View File

@ -39,11 +39,7 @@ public class Genesis extends Block {
"1a26338f0d905e295fccb71fa9ea849ffa12aaf4", // # (A)
};
Logger logger = LoggerFactory.getLogger(this.getClass());
// The proof-of-concept series include a development premine, making the state root hash
// some value stateRoot. The latest documentation should be consulted for the value of the state root.
private AccountState acct = new AccountState(BigInteger.ZERO, BigInteger.valueOf(2).pow(200));
Logger logger = LoggerFactory.getLogger("main");
private static byte[] zeroHash256 = new byte[32];
private static byte[] zeroHash160 = new byte[20];
@ -68,11 +64,14 @@ public class Genesis extends Block {
NUMBER, MIN_GAS_PRICE, GAS_LIMIT, GAS_USED, TIMESTAMP,
EXTRA_DATA, NONCE, null, null);
// Premine state
// The proof-of-concept series include a development premine, making the state root hash
// some value stateRoot. The latest documentation should be consulted for the value of the state root.
for (String address : premine) {
WorldManager.instance.repository.createAccount(Hex.decode(address));
WorldManager.instance.repository.addBalance(Hex.decode(address), BigInteger.valueOf(2).pow(200) );
WorldManager.instance.repository.addBalance (Hex.decode(address), BigInteger.valueOf(2).pow(200) );
}
this.setStateRoot( WorldManager.instance.repository.getRootHash() );
logger.info("Genesis-hash: " + Hex.toHexString(this.getHash()));
logger.info("Genesis-stateRoot: " + Hex.toHexString(this.getStateRoot()));
}

View File

@ -103,6 +103,10 @@ public class Repository {
ContractDetails details = new ContractDetails();
contractDetailsDB.put(addr, details.getEncoded());
if (logger.isInfoEnabled())
logger.info("New account created: [ {} ]", Hex.toHexString(addr));
return state;
}

View File

@ -137,8 +137,6 @@ public class BlockTest {
*/
Block genesis = Genesis.getInstance();
assertEquals(CPP_PoC5_GENESIS_HEX_RLP_ENCODED, Hex.toHexString(genesis.getEncoded()));
// Not really a good test because this compares Genesis.getHash() to itself
assertEquals(CPP_PoC5_GENESIS_HEX_HASH, Hex.toHexString(genesis.getHash()));
}