Added GetCode method

This commit is contained in:
obscuren 2014-09-08 00:50:04 +02:00
parent 0fea62ec6d
commit d91357d00c
2 changed files with 14 additions and 1 deletions

View File

@ -49,6 +49,15 @@ func (self *State) GetNonce(addr []byte) uint64 {
return 0
}
func (self *State) GetCode(addr []byte) []byte {
stateObject := self.GetStateObject(addr)
if stateObject != nil {
return stateObject.Code
}
return nil
}
//
// Setting, updating & deleting state object methods
//

View File

@ -297,8 +297,12 @@ func (c *StateObject) RlpEncode() []byte {
} else {
root = ""
}
var codeHash []byte
if len(c.Code) > 0 {
codeHash = ethcrypto.Sha3Bin(c.Code)
}
return ethutil.Encode([]interface{}{c.Nonce, c.Balance, root, ethcrypto.Sha3Bin(c.Code)})
return ethutil.Encode([]interface{}{c.Nonce, c.Balance, root, codeHash})
}
func (c *StateObject) RlpDecode(data []byte) {