Struct ethcore::state_db::StateDB  [−][src]
pub struct StateDB { /* fields omitted */ }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.
Methods
impl StateDB[src] 
impl StateDBpub fn new(db: Box<JournalDB>, cache_size: usize) -> StateDB[src] 
pub fn new(db: Box<JournalDB>, cache_size: usize) -> StateDBCreate 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: &KeyValueDB) -> Bloom[src] 
pub fn load_bloom(db: &KeyValueDB) -> BloomLoads accounts bloom from the database This bloom is used to handle request for the non-existant account fast
pub fn commit_bloom(
    batch: &mut DBTransaction, 
    journal: BloomJournal
) -> Result<()>[src] 
pub fn commit_bloom(
    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] 
pub fn journal_under(
    &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] 
pub fn mark_canonical(
    &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] 
pub fn sync_cache(
    &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_hashdb(&self) -> &HashDB<KeccakHasher>[src] 
pub fn as_hashdb(&self) -> &HashDB<KeccakHasher>Conversion method to interpret self as HashDB reference
pub fn as_hashdb_mut(&mut self) -> &mut HashDB<KeccakHasher>[src] 
pub fn as_hashdb_mut(&mut self) -> &mut HashDB<KeccakHasher>Conversion method to interpret self as mutable HashDB reference
pub fn boxed_clone(&self) -> StateDB[src] 
pub fn boxed_clone(&self) -> StateDBClone the database.
pub fn boxed_clone_canon(&self, parent: &H256) -> StateDB[src] 
pub fn boxed_clone_canon(&self, parent: &H256) -> StateDBClone the database for a canonical state.
pub fn is_pruned(&self) -> bool[src] 
pub fn is_pruned(&self) -> boolCheck if pruning is enabled on the database.
pub fn mem_used(&self) -> usize[src] 
pub fn mem_used(&self) -> usizeHeap size used.
pub fn journal_db(&self) -> &JournalDB[src] 
pub fn journal_db(&self) -> &JournalDBReturns underlying JournalDB.
pub fn cache_size(&self) -> usize[src] 
pub fn cache_size(&self) -> usizeQuery how much memory is set aside for the accounts cache (in bytes).
Trait Implementations
impl Backend for StateDB[src] 
impl Backend for StateDBfn as_hashdb(&self) -> &HashDB<KeccakHasher>[src] 
fn as_hashdb(&self) -> &HashDB<KeccakHasher>Treat the backend as a read-only hashdb.
fn as_hashdb_mut(&mut self) -> &mut HashDB<KeccakHasher>[src] 
fn as_hashdb_mut(&mut self) -> &mut HashDB<KeccakHasher>Treat the backend as a writeable hashdb.
fn add_to_account_cache(
    &mut self, 
    addr: Address, 
    data: Option<Account>, 
    modified: bool
)[src] 
fn add_to_account_cache(
    &mut self, 
    addr: Address, 
    data: Option<Account>, 
    modified: bool
)Add an account entry to the cache.
fn cache_code(&self, hash: H256, code: Arc<Vec<u8>>)[src] 
fn cache_code(&self, hash: H256, code: Arc<Vec<u8>>)Add a global code cache entry. This doesn't need to worry about canonicality because it simply maps hashes to raw code and will always be correct in the absence of hash collisions. Read more
fn get_cached_account(&self, addr: &Address) -> Option<Option<Account>>[src] 
fn get_cached_account(&self, addr: &Address) -> Option<Option<Account>>Get basic copy of the cached account. Not required to include storage. Returns 'None' if cache is disabled or if the account is not cached. Read more
fn get_cached<F, U>(&self, a: &Address, f: F) -> Option<U> where
    F: FnOnce(Option<&mut Account>) -> U, [src] 
fn get_cached<F, U>(&self, a: &Address, f: F) -> Option<U> where
    F: FnOnce(Option<&mut Account>) -> U, Get value from a cached account. None is passed to the closure if the account entry cached is known not to exist. None is returned if the entry is not cached. Read more
fn get_cached_code(&self, hash: &H256) -> Option<Arc<Vec<u8>>>[src] 
fn get_cached_code(&self, hash: &H256) -> Option<Arc<Vec<u8>>>Get cached code based on hash.
fn note_non_null_account(&self, address: &Address)[src] 
fn note_non_null_account(&self, address: &Address)Note that an account with the given address is non-null.
fn is_known_null(&self, address: &Address) -> bool[src] 
fn is_known_null(&self, address: &Address) -> boolCheck whether an account is known to be empty. Returns true if known to be empty, false otherwise. Read more