MCPcopy Create free account
hub / github.com/CPChain/chain / Code

Method Code

core/state/state_object.go:299–312  ·  view source on GitHub ↗

Code returns the contract code associated with this object, if any.

(db Database)

Source from the content-addressed store, hash-verified

297
298// Code returns the contract code associated with this object, if any.
299func (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
314func (self *stateObject) SetCode(codeHash common.Hash, code []byte) {
315 prevcode := self.Code(self.db.db)

Callers 4

SetCodeMethod · 0.95
TestSnapshot2Function · 0.80
GetCodeMethod · 0.80
RawDumpMethod · 0.80

Calls 4

CodeHashMethod · 0.95
setErrorMethod · 0.95
EqualMethod · 0.65
ContractCodeMethod · 0.65

Tested by 1

TestSnapshot2Function · 0.64