TrieWriter

Trait TrieWriter 

pub trait TrieWriter: Send + Sync {
    // Required methods
    fn write_trie_updates_sorted(
        &self,
        trie_updates: &TrieUpdatesSorted,
    ) -> Result<usize, ProviderError>;
    fn write_trie_changesets(
        &self,
        block_number: u64,
        trie_updates: &TrieUpdatesSorted,
        updates_overlay: Option<&TrieUpdatesSorted>,
    ) -> Result<usize, ProviderError>;
    fn clear_trie_changesets(&self) -> Result<(), ProviderError>;
    fn clear_trie_changesets_from(&self, from: u64) -> Result<(), ProviderError>;

    // Provided method
    fn write_trie_updates(
        &self,
        trie_updates: TrieUpdates,
    ) -> Result<usize, ProviderError> { ... }
}
Expand description

Trie Writer

Required Methods§

fn write_trie_updates_sorted( &self, trie_updates: &TrieUpdatesSorted, ) -> Result<usize, ProviderError>

Writes trie updates to the database with already sorted updates.

Returns the number of entries modified.

fn write_trie_changesets( &self, block_number: u64, trie_updates: &TrieUpdatesSorted, updates_overlay: Option<&TrieUpdatesSorted>, ) -> Result<usize, ProviderError>

Records the current values of all trie nodes which will be updated using the [TrieUpdates] into the trie changesets tables.

The intended usage of this method is to call it prior to calling write_trie_updates with the same [TrieUpdates].

The updates_overlay parameter allows providing additional in-memory trie updates that should be considered when looking up current node values. When provided, these overlay updates are applied on top of the database state, allowing the method to see a view that includes both committed database values and pending in-memory changes. This is useful when writing changesets for updates that depend on previous uncommitted trie changes.

Returns the number of keys written.

fn clear_trie_changesets(&self) -> Result<(), ProviderError>

Clears contents of trie changesets completely

fn clear_trie_changesets_from(&self, from: u64) -> Result<(), ProviderError>

Clears contents of trie changesets starting from the given block number (inclusive) onwards.

Provided Methods§

fn write_trie_updates( &self, trie_updates: TrieUpdates, ) -> Result<usize, ProviderError>

Writes trie updates to the database.

Returns the number of entries modified.

Implementations on Foreign Types§

§

impl<'a, T> TrieWriter for &'a T
where T: 'a + TrieWriter + ?Sized, &'a T: Send + Sync,

§

fn write_trie_updates( &self, trie_updates: TrieUpdates, ) -> Result<usize, ProviderError>

§

fn write_trie_updates_sorted( &self, trie_updates: &TrieUpdatesSorted, ) -> Result<usize, ProviderError>

§

fn write_trie_changesets( &self, block_number: u64, trie_updates: &TrieUpdatesSorted, updates_overlay: Option<&TrieUpdatesSorted>, ) -> Result<usize, ProviderError>

§

fn clear_trie_changesets(&self) -> Result<(), ProviderError>

§

fn clear_trie_changesets_from(&self, from: u64) -> Result<(), ProviderError>

§

impl<T> TrieWriter for Box<T>
where T: TrieWriter + ?Sized, Box<T>: Send + Sync,

§

fn write_trie_updates( &self, trie_updates: TrieUpdates, ) -> Result<usize, ProviderError>

§

fn write_trie_updates_sorted( &self, trie_updates: &TrieUpdatesSorted, ) -> Result<usize, ProviderError>

§

fn write_trie_changesets( &self, block_number: u64, trie_updates: &TrieUpdatesSorted, updates_overlay: Option<&TrieUpdatesSorted>, ) -> Result<usize, ProviderError>

§

fn clear_trie_changesets(&self) -> Result<(), ProviderError>

§

fn clear_trie_changesets_from(&self, from: u64) -> Result<(), ProviderError>

§

impl<T> TrieWriter for Arc<T>
where T: TrieWriter + ?Sized, Arc<T>: Send + Sync,

§

fn write_trie_updates( &self, trie_updates: TrieUpdates, ) -> Result<usize, ProviderError>

§

fn write_trie_updates_sorted( &self, trie_updates: &TrieUpdatesSorted, ) -> Result<usize, ProviderError>

§

fn write_trie_changesets( &self, block_number: u64, trie_updates: &TrieUpdatesSorted, updates_overlay: Option<&TrieUpdatesSorted>, ) -> Result<usize, ProviderError>

§

fn clear_trie_changesets(&self) -> Result<(), ProviderError>

§

fn clear_trie_changesets_from(&self, from: u64) -> Result<(), ProviderError>

Implementors§

Source§

impl<TX: DbTxMut + DbTx + 'static, N: NodeTypes> TrieWriter for DatabaseProvider<TX, N>