Journal
JournalDB
- class eth.db.journal.JournalDB(wrapped_db: DatabaseAPI)
A wrapper around the basic DB objects that keeps a journal of all changes. Checkpoints can be recorded at any time. You can then commit or roll back to those checkpoints.
Discarding a checkpoint throws away all changes that happened since that checkpoint. Committing a checkpoint simply removes the option of reverting back to it later.
Nothing is written to the underlying db until persist() is called.
The added memory footprint for a JournalDB is one key/value stored per database key which is changed, at each checkpoint. Subsequent changes to the same key between two checkpoints will not increase the journal size, since we do not permit reverting to a place that has no checkpoint.
- clear() None
Remove all keys. Immediately after a clear, all getitem requests will return a KeyError. That includes the changes pending persist and any data in the underlying database.
(This action is journaled, like all other actions)
clear will not persist the emptying of all keys in the underlying DB. It only prevents any updates (or deletes!) before it from being persisted.
Any caller that wants to use clear must also make sure that the underlying database reflects their desired end state (maybe emptied, maybe not).
- diff() DBDiff
Generate a DBDiff of all pending changes. These are the changes that would occur if
persist()
were called.
- discard(checkpoint: JournalDBCheckpoint) None
Throws away all journaled data starting at the given checkpoint
- persist() None
Persist all changes in underlying db. After all changes have been written the JournalDB starts a new recording.
- commit
- record