reth::providers

Trait BlockWriter

pub trait BlockWriter: Send + Sync {
    type Block: Block;
    type Receipt: Send + Sync;

    // Required methods
    fn insert_block(
        &self,
        block: SealedBlockWithSenders<Self::Block>,
        write_to: StorageLocation,
    ) -> Result<StoredBlockBodyIndices, ProviderError>;
    fn append_block_bodies(
        &self,
        bodies: Vec<(u64, Option<<Self::Block as Block>::Body>)>,
        write_to: StorageLocation,
    ) -> Result<(), ProviderError>;
    fn remove_blocks_above(
        &self,
        block: u64,
        remove_from: StorageLocation,
    ) -> Result<(), ProviderError>;
    fn remove_bodies_above(
        &self,
        block: u64,
        remove_from: StorageLocation,
    ) -> Result<(), ProviderError>;
    fn append_blocks_with_state(
        &self,
        blocks: Vec<SealedBlockWithSenders<Self::Block>>,
        execution_outcome: ExecutionOutcome<Self::Receipt>,
        hashed_state: HashedPostStateSorted,
        trie_updates: TrieUpdates,
    ) -> Result<(), ProviderError>;
}
Expand description

Block Writer

Required Associated Types§

type Block: Block

The body this writer can write.

type Receipt: Send + Sync

The receipt type for ExecutionOutcome.

Required Methods§

fn insert_block( &self, block: SealedBlockWithSenders<Self::Block>, write_to: StorageLocation, ) -> Result<StoredBlockBodyIndices, ProviderError>

Insert full block and make it canonical. Parent tx num and transition id is taken from parent block in database.

Return [StoredBlockBodyIndices] that contains indices of the first and last transactions and transition in the block.

Accepts StorageLocation value which specifies where transactions and headers should be written.

fn append_block_bodies( &self, bodies: Vec<(u64, Option<<Self::Block as Block>::Body>)>, write_to: StorageLocation, ) -> Result<(), ProviderError>

Appends a batch of block bodies extending the canonical chain. This is invoked during Bodies stage and does not write to TransactionHashNumbers and TransactionSenders tables which are populated on later stages.

Bodies are passed as Options, if body is None the corresponding block is empty.

fn remove_blocks_above( &self, block: u64, remove_from: StorageLocation, ) -> Result<(), ProviderError>

Removes all blocks above the given block number from the database.

Note: This does not remove state or execution data.

fn remove_bodies_above( &self, block: u64, remove_from: StorageLocation, ) -> Result<(), ProviderError>

Removes all block bodies above the given block number from the database.

fn append_blocks_with_state( &self, blocks: Vec<SealedBlockWithSenders<Self::Block>>, execution_outcome: ExecutionOutcome<Self::Receipt>, hashed_state: HashedPostStateSorted, trie_updates: TrieUpdates, ) -> Result<(), ProviderError>

Appends a batch of sealed blocks to the blockchain, including sender information, and updates the post-state.

Inserts the blocks into the database and updates the state with provided BundleState.

§Parameters
  • blocks: Vector of SealedBlockWithSenders instances to append.
  • state: Post-state information to update after appending.
§Returns

Returns Ok(()) on success, or an error if any operation fails.

Implementations on Foreign Types§

§

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

§

type Block = <T as BlockWriter>::Block

§

type Receipt = <T as BlockWriter>::Receipt

§

fn insert_block( &self, block: SealedBlockWithSenders<<&'a T as BlockWriter>::Block>, write_to: StorageLocation, ) -> Result<StoredBlockBodyIndices, ProviderError>

§

fn append_block_bodies( &self, bodies: Vec<(u64, Option<<<&'a T as BlockWriter>::Block as Block>::Body>)>, write_to: StorageLocation, ) -> Result<(), ProviderError>

§

fn remove_blocks_above( &self, block: u64, remove_from: StorageLocation, ) -> Result<(), ProviderError>

§

fn remove_bodies_above( &self, block: u64, remove_from: StorageLocation, ) -> Result<(), ProviderError>

§

fn append_blocks_with_state( &self, blocks: Vec<SealedBlockWithSenders<<&'a T as BlockWriter>::Block>>, execution_outcome: ExecutionOutcome<<&'a T as BlockWriter>::Receipt>, hashed_state: HashedPostStateSorted, trie_updates: TrieUpdates, ) -> Result<(), ProviderError>

§

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

§

type Block = <T as BlockWriter>::Block

§

type Receipt = <T as BlockWriter>::Receipt

§

fn insert_block( &self, block: SealedBlockWithSenders<<Box<T> as BlockWriter>::Block>, write_to: StorageLocation, ) -> Result<StoredBlockBodyIndices, ProviderError>

§

fn append_block_bodies( &self, bodies: Vec<(u64, Option<<<Box<T> as BlockWriter>::Block as Block>::Body>)>, write_to: StorageLocation, ) -> Result<(), ProviderError>

§

fn remove_blocks_above( &self, block: u64, remove_from: StorageLocation, ) -> Result<(), ProviderError>

§

fn remove_bodies_above( &self, block: u64, remove_from: StorageLocation, ) -> Result<(), ProviderError>

§

fn append_blocks_with_state( &self, blocks: Vec<SealedBlockWithSenders<<Box<T> as BlockWriter>::Block>>, execution_outcome: ExecutionOutcome<<Box<T> as BlockWriter>::Receipt>, hashed_state: HashedPostStateSorted, trie_updates: TrieUpdates, ) -> Result<(), ProviderError>

§

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

§

type Block = <T as BlockWriter>::Block

§

type Receipt = <T as BlockWriter>::Receipt

§

fn insert_block( &self, block: SealedBlockWithSenders<<Arc<T> as BlockWriter>::Block>, write_to: StorageLocation, ) -> Result<StoredBlockBodyIndices, ProviderError>

§

fn append_block_bodies( &self, bodies: Vec<(u64, Option<<<Arc<T> as BlockWriter>::Block as Block>::Body>)>, write_to: StorageLocation, ) -> Result<(), ProviderError>

§

fn remove_blocks_above( &self, block: u64, remove_from: StorageLocation, ) -> Result<(), ProviderError>

§

fn remove_bodies_above( &self, block: u64, remove_from: StorageLocation, ) -> Result<(), ProviderError>

§

fn append_blocks_with_state( &self, blocks: Vec<SealedBlockWithSenders<<Arc<T> as BlockWriter>::Block>>, execution_outcome: ExecutionOutcome<<Arc<T> as BlockWriter>::Receipt>, hashed_state: HashedPostStateSorted, trie_updates: TrieUpdates, ) -> Result<(), ProviderError>

Implementors§

§

impl<TX, N> BlockWriter for DatabaseProvider<TX, N>
where TX: DbTxMut + DbTx + 'static, N: NodeTypesForProvider + 'static,