updateTrie writes cached storage modifications into the object's storage trie.
(db Database)
| 199 | |
| 200 | // updateTrie writes cached storage modifications into the object's storage trie. |
| 201 | func (self *stateObject) updateTrie(db Database) Trie { |
| 202 | tr := self.getTrie(db) |
| 203 | for key, value := range self.dirtyStorage { |
| 204 | delete(self.dirtyStorage, key) |
| 205 | if (value == common.Hash{}) { |
| 206 | self.setError(tr.TryDelete(key[:])) |
| 207 | continue |
| 208 | } |
| 209 | // Encoding []byte cannot fail, ok to ignore the error. |
| 210 | v, _ := rlp.EncodeToBytes(bytes.TrimLeft(value[:], "\x00")) |
| 211 | self.setError(tr.TryUpdate(key[:], v)) |
| 212 | } |
| 213 | return tr |
| 214 | } |
| 215 | |
| 216 | // UpdateRoot sets the trie root to the current root hash of |
| 217 | func (self *stateObject) updateRoot(db Database) { |
no test coverage detected