Storage
AccountStorageDB
- class eth.db.storage.AccountStorageDB(db: AtomicDatabaseAPI, storage_root: Hash32, address: Address)
-
- get(slot: int, from_journal: bool = True) int
Return the value at
slot
. Lookups take the journal into consideration unlessfrom_journal
is explicitly set toFalse
.
- get_accessed_slots() FrozenSet[int]
List all the slots that had been accessed since object creation.
- get_changed_root() Hash32
Return the changed root hash. Raise
ValidationError
if the root has not changed.
- lock_changes() None
Locks in changes to storage, typically just as a transaction starts.
This is used, for example, to look up the storage value from the start of the transaction, when calculating gas costs in EIP-2200: net gas metering.
- persist(db: DatabaseAPI) None
Persist all changes to the database.
- logger = <ExtendedDebugLogger eth.db.storage.AccountStorageDB (WARNING)>
StorageLookup
- class eth.db.storage.StorageLookup(db: DatabaseAPI, storage_root: Hash32, address: Address)
This lookup converts lookups of storage slot integers into the appropriate trie lookup. Similarly, it persists changes to the appropriate trie at write time.
StorageLookup also tracks the state roots changed since the last persist.
- commit_to(db: DatabaseAPI) None
Trying to commit changes when nothing has been written will raise a ValidationError
- get_changed_root() Hash32
- new_trie() int
Switch to an empty trie. Save the old trie, and pending writes, in case of a revert.
- Returns:
index for reviving the previous trie
- rollback_trie(trie_index: int) None
Revert back to the previous trie, using the index returned by a
new_trie()
call. The index returned by that call returns you to the trie in place before the call.- Parameters:
trie_index – index for reviving the previous trie
- logger = <ExtendedDebugLogger eth.db.storage.StorageLookup (WARNING)>