New Repositroy management:

+ Block stateRoot hack
This commit is contained in:
romanman 2014-06-25 00:37:38 +01:00
parent 59ff195854
commit 79ad0d6869
2 changed files with 12 additions and 6 deletions

View File

@ -72,10 +72,9 @@ public class Block {
timestamp, extraData, nonce);
this.txsState = new Trie(null);
// TODO: REFACTOR REPOSITORY TO GET ROOT HASH FOR HERE
// TODO: REFACTOR REPOSITORY TO GET ROOT HASH FOR HERE
// TODO: REFACTOR REPOSITORY TO GET ROOT HASH FOR HERE
this.header.setStateRoot(null);
byte[] stateRoot = WorldManager.instance.repository.getRootHash();
this.header.setStateRoot(stateRoot);
this.header.setTxTrieRoot(txsState.getRootHash());
this.transactionsList = transactionsList;
this.uncleList = uncleList;

View File

@ -37,6 +37,8 @@ public class Repository {
private Logger logger = LoggerFactory.getLogger("repository");
Trie worldState;
TrackTrie accountStateDB;
TrackDatabase contractDetailsDB;
@ -54,7 +56,8 @@ public class Repository {
stateDB = new DatabaseImpl("state");
Trie worldState = new Trie(stateDB.getDb());
worldState = new Trie(stateDB.getDb());
accountStateDB = new TrackTrie(worldState);
}
@ -142,7 +145,7 @@ public class Repository {
if (logger.isInfoEnabled())
logger.info("Changing balance: account: [ {} ] new balance: [ {} ]",
Hex.toHexString(address), newBalance.longValue());
Hex.toHexString(address), newBalance.toString());
accountStateDB.update(address, state.getEncoded());
@ -247,6 +250,10 @@ public class Repository {
contractDetailsDB.put(address, details.getEncoded());
}
public byte[] getRootHash(){
return this.worldState.getRootHash();
}
public void close(){