Struct state_db::StateDB [−][src]
State database abstraction.
Manages shared global state cache which reflects the canonical
state as it is on the disk. All the entries in the cache are clean.
A clone of StateDB
may be created as canonical or not.
For canonical clones local cache is accumulated and applied
in sync_cache
For non-canonical clones local cache is dropped.
Global cache propagation.
After a State
object has been committed to the trie it
propagates its local cache into the StateDB
local cache
using add_to_account_cache
function.
Then, after the block has been added to the chain the local cache in the
StateDB
is propagated into the global cache.
Implementations
impl StateDB
[src]
pub fn new(db: Box<dyn JournalDB>, cache_size: usize) -> StateDB
[src]
Create a new instance wrapping JournalDB
and the maximum allowed size
of the LRU cache in bytes. Actual used memory may (read: will) be higher due to bookkeeping.
pub fn load_bloom(db: &dyn KeyValueDB) -> Bloom
[src]
Loads accounts bloom from the database This bloom is used to handle request for the non-existent account fast
pub fn commit_bloom(
batch: &mut DBTransaction,
journal: BloomJournal
) -> Result<()>
[src]
batch: &mut DBTransaction,
journal: BloomJournal
) -> Result<()>
Commit blooms journal to the database transaction
pub fn journal_under(
&mut self,
batch: &mut DBTransaction,
now: u64,
id: &H256
) -> Result<u32>
[src]
&mut self,
batch: &mut DBTransaction,
now: u64,
id: &H256
) -> Result<u32>
Journal all recent operations under the given era and ID.
pub fn mark_canonical(
&mut self,
batch: &mut DBTransaction,
end_era: u64,
canon_id: &H256
) -> Result<u32>
[src]
&mut self,
batch: &mut DBTransaction,
end_era: u64,
canon_id: &H256
) -> Result<u32>
Mark a given candidate from an ancient era as canonical, enacting its removals from the backing database and reverting any non-canonical historical commit’s insertions.
pub fn sync_cache(
&mut self,
enacted: &[H256],
retracted: &[H256],
is_best: bool
)
[src]
&mut self,
enacted: &[H256],
retracted: &[H256],
is_best: bool
)
Propagate local cache into the global cache and synchonize
the global cache with the best block state.
This function updates the global cache by removing entries
that are invalidated by chain reorganization. sync_cache
should be called after the block has been committed and the
blockchain route has ben calculated.
pub fn as_hash_db(&self) -> &dyn HashDB<KeccakHasher, DBValue>
[src]
Conversion method to interpret self as HashDB
reference
pub fn as_hash_db_mut(&mut self) -> &mut dyn HashDB<KeccakHasher, DBValue>
[src]
Conversion method to interpret self as mutable HashDB
reference
pub fn boxed_clone(&self) -> StateDB
[src]
Clone the database.
pub fn boxed_clone_canon(&self, parent: &H256) -> StateDB
[src]
Clone the database for a canonical state.
pub fn is_prunable(&self) -> bool
[src]
Check if pruning is enabled on the database.
pub fn mem_used(&self) -> usize
[src]
Heap size used.
pub fn journal_db(&self) -> &dyn JournalDB
[src]
Returns underlying JournalDB
.
pub fn cache_size(&self) -> usize
[src]
Query how much memory is set aside for the accounts cache (in bytes).
Trait Implementations
impl Backend for StateDB
[src]
fn as_hash_db(&self) -> &dyn HashDB<KeccakHasher, DBValue>
[src]
fn as_hash_db_mut(&mut self) -> &mut dyn HashDB<KeccakHasher, DBValue>
[src]
fn add_to_account_cache(
&mut self,
address: Address,
data: Option<Account>,
modified: bool
)
[src]
&mut self,
address: Address,
data: Option<Account>,
modified: bool
)
fn cache_code(&self, hash: H256, code: Arc<Vec<u8>>)
[src]
fn get_cached_account(&self, addr: &Address) -> Option<Option<Account>>
[src]
fn get_cached<F, U>(&self, a: &Address, f: F) -> Option<U> where
F: FnOnce(Option<&mut Account>) -> U,
[src]
F: FnOnce(Option<&mut Account>) -> U,
fn get_cached_code(&self, hash: &H256) -> Option<Arc<Vec<u8>>>
[src]
fn note_non_null_account(&self, address: &Address)
[src]
fn is_known_null(&self, address: &Address) -> bool
[src]
impl Clone for StateDB
[src]
fn clone(&self) -> Self
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
Auto Trait Implementations
impl !RefUnwindSafe for StateDB
impl Send for StateDB
impl Sync for StateDB
impl Unpin for StateDB
impl !UnwindSafe for StateDB
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,