Added address to account and contract

Contract and account now both have an address field or method for the
sake of simplicity.
This commit is contained in:
obscuren
2014-03-20 23:38:16 +01:00
parent 7705b23f24
commit f567f89b99
5 changed files with 38 additions and 26 deletions

View File

@ -63,8 +63,7 @@ func (s *State) GetContract(addr []byte) *Contract {
}
// build contract
contract := &Contract{}
contract.RlpDecode([]byte(data))
contract := NewContractFromBytes(addr, []byte(data))
// Check if there's a cached state for this contract
cachedState := s.states[string(addr)]
@ -78,7 +77,9 @@ func (s *State) GetContract(addr []byte) *Contract {
return contract
}
func (s *State) UpdateContract(addr []byte, contract *Contract) {
func (s *State) UpdateContract(contract *Contract) {
addr := contract.Address()
s.states[string(addr)] = contract.state
s.trie.Update(string(addr), string(contract.RlpEncode()))
}