Recalculate trie only when necessary
This commit is contained in:
parent
31fddb591b
commit
59d8dfbed0
|
@ -94,7 +94,11 @@ public class ContractDetails {
|
|||
|
||||
public byte[] getStorageHash() {
|
||||
|
||||
getEncoded();
|
||||
storageTrie = new Trie(null);
|
||||
// calc the trie for root hash
|
||||
for (int i = 0; i < storageKeys.size(); ++i){
|
||||
storageTrie.update(storageKeys.get(i).getData(), RLP.encodeElement( storageValues.get(i).getNoLeadZeroesData() ));
|
||||
}
|
||||
return storageTrie.getRootHash();
|
||||
}
|
||||
|
||||
|
@ -149,12 +153,6 @@ public class ContractDetails {
|
|||
values[i] = RLP.encodeElement(value.getNoLeadZeroesData());
|
||||
}
|
||||
|
||||
storageTrie = new Trie(null);
|
||||
// calc the trie for root hash
|
||||
for (int i = 0; i < storageKeys.size(); ++i){
|
||||
storageTrie.update(storageKeys.get(i).getData(), values[i]);
|
||||
}
|
||||
|
||||
byte[] rlpKeysList = RLP.encodeList(keys);
|
||||
byte[] rlpValuesList = RLP.encodeList(values);
|
||||
byte[] rlpCode = RLP.encodeElement(code);
|
||||
|
|
Loading…
Reference in New Issue