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

Method GetState

core/state/state_object.go:163–183  ·  view source on GitHub ↗

GetState returns a value in account storage.

(db Database, key common.Hash)

Source from the content-addressed store, hash-verified

161
162// GetState returns a value in account storage.
163func (self *stateObject) GetState(db Database, key common.Hash) common.Hash {
164 value, exists := self.cachedStorage[key]
165 if exists {
166 return value
167 }
168 // Load from DB in case it is missing.
169 enc, err := self.getTrie(db).TryGet(key[:])
170 if err != nil {
171 self.setError(err)
172 return common.Hash{}
173 }
174 if len(enc) > 0 {
175 _, content, _, err := rlp.Split(enc)
176 if err != nil {
177 self.setError(err)
178 }
179 value.SetBytes(content)
180 }
181 self.cachedStorage[key] = value
182 return value
183}
184
185// SetState updates a value in account storage.
186func (self *stateObject) SetState(db Database, key, value common.Hash) {

Callers 1

SetStateMethod · 0.95

Calls 4

getTrieMethod · 0.95
setErrorMethod · 0.95
TryGetMethod · 0.80
SetBytesMethod · 0.80

Tested by

no test coverage detected