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

Method getStateObject

core/state/statedb.go:362–386  ·  view source on GitHub ↗

Retrieve a state object given by the address. Returns nil if not found.

(addr common.Address)

Source from the content-addressed store, hash-verified

360
361// Retrieve a state object given by the address. Returns nil if not found.
362func (self *StateDB) getStateObject(addr common.Address) (stateObject *stateObject) {
363 // Prefer 'live' objects.
364 if obj := self.stateObjects[addr]; obj != nil {
365 if obj.deleted {
366 return nil
367 }
368 return obj
369 }
370
371 // Load the object from the database.
372 enc, err := self.trie.TryGet(addr[:])
373 if len(enc) == 0 {
374 self.setError(err)
375 return nil
376 }
377 var data Account
378 if err := rlp.DecodeBytes(enc, &data); err != nil {
379 log.Error("Failed to decode state object", "addr", addr, "err", err)
380 return nil
381 }
382 // Insert into the live set.
383 obj := newObject(self, addr, data)
384 self.setStateObject(obj)
385 return obj
386}
387
388func (self *StateDB) setStateObject(object *stateObject) {
389 self.stateObjects[object.Address()] = object

Callers 15

ExistMethod · 0.95
EmptyMethod · 0.95
GetBalanceMethod · 0.95
GetNonceMethod · 0.95
GetCodeMethod · 0.95
GetCodeSizeMethod · 0.95
GetCodeHashMethod · 0.95
GetStateMethod · 0.95
StorageTrieMethod · 0.95
HasSuicidedMethod · 0.95
SuicideMethod · 0.95
GetOrNewStateObjectMethod · 0.95

Calls 5

setErrorMethod · 0.95
setStateObjectMethod · 0.95
newObjectFunction · 0.85
TryGetMethod · 0.80
ErrorMethod · 0.65

Tested by 3

TestSnapshot2Function · 0.64
checkEqualMethod · 0.64
createFunction · 0.64