preparing for state finalization
This commit is contained in:
parent
3f7891ff36
commit
9f70c014a1
|
@ -3,6 +3,7 @@ package org.ethereum.core;
|
|||
import org.ethereum.crypto.ECKey;
|
||||
import org.ethereum.crypto.HashUtil;
|
||||
import org.ethereum.util.RLP;
|
||||
import org.ethereum.util.RLPList;
|
||||
import org.ethereum.util.Utils;
|
||||
|
||||
import java.math.BigInteger;
|
||||
|
@ -45,7 +46,17 @@ public class AccountState {
|
|||
}
|
||||
|
||||
public AccountState(ECKey ecKey) {
|
||||
this(ecKey, BigInteger.ZERO, BigInteger.ZERO);
|
||||
this(ecKey, BigInteger.ZERO, BigInteger.ZERO);
|
||||
}
|
||||
|
||||
public AccountState(byte[] rlpData){
|
||||
this.rlpEncoded = rlpData;
|
||||
|
||||
RLPList items = (RLPList)RLP.decode2(rlpEncoded).get(0);
|
||||
this.nonce = new BigInteger(1, ((items.get(0).getRLPData()) == null ? new byte[]{} : items.get(0).getRLPData()));
|
||||
this.balance = new BigInteger(1, items.get(1).getRLPData());
|
||||
this.stateRoot = items.get(2).getRLPData();
|
||||
this.codeHash = items.get(3).getRLPData();
|
||||
}
|
||||
|
||||
public AccountState(ECKey ecKey, BigInteger nonce, BigInteger balance) {
|
||||
|
@ -71,6 +82,8 @@ public class AccountState {
|
|||
this.nonce = nonce.add(BigInteger.ONE);
|
||||
}
|
||||
|
||||
public void setCodeHash(byte[] codeHash){ this.codeHash = codeHash; }
|
||||
|
||||
public BigInteger getBalance() {
|
||||
return balance;
|
||||
}
|
||||
|
|
|
@ -109,6 +109,19 @@ public class Trie {
|
|||
return c.asBytes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a value from a node
|
||||
*
|
||||
* @param key
|
||||
* @return value
|
||||
*/
|
||||
public byte[] get(byte[] key) {
|
||||
byte[] k = binToNibbles(key);
|
||||
Value c = new Value( this.get(this.root, k) );
|
||||
return c.asBytes();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete a key/value pair from the trie
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue