DBDiff(changes: Dict[bytes, Union[bytes, eth.db.diff.MissingReason]] = None)¶
DBDiff is a read-only view of the updates/inserts and deletes generated when tracking changes with
The primary usage is to apply these changes to your underlying database with
apply_to(db: collections.abc.MutableMapping, apply_deletes: bool = True) → None¶
Apply the changes in this diff to the given database. You may choose to opt out of deleting any underlying keys.
Parameters: apply_deletes – whether the pending deletes should be applied to the database
deleted_keys() → Iterable[bytes]¶
List all the keys that have been deleted.
join(diffs: Iterable[DBDiff]) → eth.db.diff.DBDiff¶
Join several DBDiff objects into a single DBDiff object.
In case of a conflict, changes in diffs that come later in
diffswill overwrite changes from earlier changes.
pending_items() → Iterable[Tuple[bytes, bytes]]¶
A tuple of (key, value) pairs for every key that has been updated. Like
pending_keys(), this does not return any deleted keys.
pending_keys() → Iterable[bytes]¶
List all the keys who have had values change. This IGNORES any keys that have been deleted.
Records changes to a
If no value is available for a key, it could be for one of two reasons: - the key was never updated during tracking - the key was deleted at some point
When getting a value, a special subtype of KeyError is raised on failure. The exception,
DiffMissingError, can be used to check if the value was deleted, or never present, using
When it’s time to take the tracked changes and write them to your database, get the
DBDiffTracker.diff()and use the attached methods.