Storage

AccountStorageDB

class eth.db.storage.AccountStorageDB(db: eth.abc.AtomicDatabaseAPI, storage_root: NewType.<locals>.new_type, address: NewType.<locals>.new_type)
commit(checkpoint: NewType.<locals>.new_type) → None

Collapse changes into the given checkpoint.

delete() → None

Delete the entire storage at the account.

discard(checkpoint: NewType.<locals>.new_type) → None

Discard the given checkpoint.

get(slot: int, from_journal: bool = True) → int

Return the value at slot. Lookups take the journal into consideration unless from_journal is explicitly set to False.

get_accessed_slots() → FrozenSet[int]

List all the slots that had been accessed since object creation.

get_changed_root() → NewType.<locals>.new_type

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.

make_storage_root() → None

Force calculation of the storage root for this account

persist(db: eth.abc.DatabaseAPI) → None

Persist all changes to the database.

record(checkpoint: NewType.<locals>.new_type) → None

Record changes into the given checkpoint.

set(slot: int, value: int) → None

Write value into slot.

has_changed_root

Return True if the storage root has changed.

StorageLookup

class eth.db.storage.StorageLookup(db: eth.abc.DatabaseAPI, storage_root: NewType.<locals>.new_type, address: NewType.<locals>.new_type)

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: eth.abc.DatabaseAPI) → None

Trying to commit changes when nothing has been written will raise a ValidationError

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