pub struct OverlayDB { /* private fields */ }
Expand description
Implementation of the HashDB
trait for a disk-backed database with a memory overlay.
The operations insert()
and remove()
take place on the memory overlay; batches of
such operations may be flushed to the disk-backed DB with commit()
or discarded with
revert()
.
lookup()
and contains()
maintain normal behaviour - all insert()
and remove()
queries have an immediate effect in terms of these functions.
Implementations
sourceimpl OverlayDB
impl OverlayDB
sourcepub fn new(backing: Arc<dyn KeyValueDB>, col: Option<u32>) -> OverlayDB
pub fn new(backing: Arc<dyn KeyValueDB>, col: Option<u32>) -> OverlayDB
Create a new instance of OverlayDB given a backing
database.
sourcepub fn commit_to_batch(&mut self, batch: &mut DBTransaction) -> Result<u32>
pub fn commit_to_batch(&mut self, batch: &mut DBTransaction) -> Result<u32>
Commit all operations to given batch.
sourcepub fn revert(&mut self)
pub fn revert(&mut self)
Revert all operations on this object (i.e. insert()
s and remove()
s) since the
last commit()
.
sourcepub fn commit_refs(&self, key: &H256) -> i32
pub fn commit_refs(&self, key: &H256) -> i32
Get the number of references that would be committed.
Trait Implementations
sourceimpl AsHashDB<KeccakHasher, ElasticArray128<u8>> for OverlayDB
impl AsHashDB<KeccakHasher, ElasticArray128<u8>> for OverlayDB
sourcefn as_hash_db(&self) -> &dyn HashDB<KeccakHasher, DBValue>
fn as_hash_db(&self) -> &dyn HashDB<KeccakHasher, DBValue>
Perform upcast to HashDB for anything that derives from HashDB.
sourcefn as_hash_db_mut(&mut self) -> &mut dyn HashDB<KeccakHasher, DBValue>
fn as_hash_db_mut(&mut self) -> &mut dyn HashDB<KeccakHasher, DBValue>
Perform mutable upcast to HashDB for anything that derives from HashDB.
sourceimpl AsKeyedHashDB for OverlayDB
impl AsKeyedHashDB for OverlayDB
sourcefn as_keyed_hash_db(&self) -> &dyn KeyedHashDB
fn as_keyed_hash_db(&self) -> &dyn KeyedHashDB
Perform upcast to KeyedHashDB.
sourceimpl HashDB<KeccakHasher, ElasticArray128<u8>> for OverlayDB
impl HashDB<KeccakHasher, ElasticArray128<u8>> for OverlayDB
sourcefn get(&self, key: &H256) -> Option<DBValue>
fn get(&self, key: &H256) -> Option<DBValue>
Look up a given hash into the bytes that hash to it, returning None if the hash is not known. Read more
sourcefn insert(&mut self, value: &[u8]) -> H256
fn insert(&mut self, value: &[u8]) -> H256
Insert a datum item into the DB and return the datum’s hash for a later lookup. Insertions
are counted and the equivalent number of remove()
s must be performed before the data
is considered dead. Read more
Auto Trait Implementations
impl !RefUnwindSafe for OverlayDB
impl Send for OverlayDB
impl Sync for OverlayDB
impl Unpin for OverlayDB
impl !UnwindSafe for OverlayDB
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more