TrieWriter

Trait TrieWriter 

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

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

Trie Writer

Required Methods§

Source

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

Writes trie updates to the database with already sorted updates.

Returns the number of entries modified.

Source

fn write_trie_changesets( &self, block_number: BlockNumber, trie_updates: &TrieUpdatesSorted, updates_overlay: Option<&TrieUpdatesSorted>, ) -> ProviderResult<usize>

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.

Source

fn clear_trie_changesets(&self) -> ProviderResult<()>

Clears contents of trie changesets completely

Source

fn clear_trie_changesets_from(&self, from: BlockNumber) -> ProviderResult<()>

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

Provided Methods§

Source

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

Writes trie updates to the database.

Returns the number of entries modified.

Implementations on Foreign Types§

Source§

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

Source§

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

Source§

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

Source§

fn write_trie_changesets( &self, block_number: BlockNumber, trie_updates: &TrieUpdatesSorted, updates_overlay: Option<&TrieUpdatesSorted>, ) -> ProviderResult<usize>

Source§

fn clear_trie_changesets(&self) -> ProviderResult<()>

Source§

fn clear_trie_changesets_from(&self, from: BlockNumber) -> ProviderResult<()>

Source§

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

Source§

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

Source§

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

Source§

fn write_trie_changesets( &self, block_number: BlockNumber, trie_updates: &TrieUpdatesSorted, updates_overlay: Option<&TrieUpdatesSorted>, ) -> ProviderResult<usize>

Source§

fn clear_trie_changesets(&self) -> ProviderResult<()>

Source§

fn clear_trie_changesets_from(&self, from: BlockNumber) -> ProviderResult<()>

Source§

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

Source§

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

Source§

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

Source§

fn write_trie_changesets( &self, block_number: BlockNumber, trie_updates: &TrieUpdatesSorted, updates_overlay: Option<&TrieUpdatesSorted>, ) -> ProviderResult<usize>

Source§

fn clear_trie_changesets(&self) -> ProviderResult<()>

Source§

fn clear_trie_changesets_from(&self, from: BlockNumber) -> ProviderResult<()>

Implementors§