Code returns the contract code associated with this object, if any.
(db Database)
| 297 | |
| 298 | // Code returns the contract code associated with this object, if any. |
| 299 | func (self *stateObject) Code(db Database) []byte { |
| 300 | if self.code != nil { |
| 301 | return self.code |
| 302 | } |
| 303 | if bytes.Equal(self.CodeHash(), emptyCodeHash) { |
| 304 | return nil |
| 305 | } |
| 306 | code, err := db.ContractCode(self.addrHash, common.BytesToHash(self.CodeHash())) |
| 307 | if err != nil { |
| 308 | self.setError(fmt.Errorf("can't load code hash %x: %v", self.CodeHash(), err)) |
| 309 | } |
| 310 | self.code = code |
| 311 | return code |
| 312 | } |
| 313 | |
| 314 | func (self *stateObject) SetCode(codeHash common.Hash, code []byte) { |
| 315 | prevcode := self.Code(self.db.db) |