reth_provider

Trait BlockWriter

Source
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,
    ) -> ProviderResult<StoredBlockBodyIndices>;
    fn append_block_bodies(
        &self,
        bodies: Vec<(BlockNumber, Option<<Self::Block as Block>::Body>)>,
        write_to: StorageLocation,
    ) -> ProviderResult<()>;
    fn remove_blocks_above(
        &self,
        block: BlockNumber,
        remove_from: StorageLocation,
    ) -> ProviderResult<()>;
    fn remove_bodies_above(
        &self,
        block: BlockNumber,
        remove_from: StorageLocation,
    ) -> ProviderResult<()>;
    fn append_blocks_with_state(
        &self,
        blocks: Vec<SealedBlockWithSenders<Self::Block>>,
        execution_outcome: ExecutionOutcome<Self::Receipt>,
        hashed_state: HashedPostStateSorted,
        trie_updates: TrieUpdates,
    ) -> ProviderResult<()>;
}
Expand description

Block Writer

Required Associated Types§

Source

type Block: Block

The body this writer can write.

Source

type Receipt: Send + Sync

The receipt type for ExecutionOutcome.

Required Methods§

Source

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

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.

Source

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

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.

Source

fn remove_blocks_above( &self, block: BlockNumber, remove_from: StorageLocation, ) -> ProviderResult<()>

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

Note: This does not remove state or execution data.

Source

fn remove_bodies_above( &self, block: BlockNumber, remove_from: StorageLocation, ) -> ProviderResult<()>

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

Source

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

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§

Source§

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

Source§

type Block = <T as BlockWriter>::Block

Source§

type Receipt = <T as BlockWriter>::Receipt

Source§

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

Source§

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

Source§

fn remove_blocks_above( &self, block: BlockNumber, remove_from: StorageLocation, ) -> ProviderResult<()>

Source§

fn remove_bodies_above( &self, block: BlockNumber, remove_from: StorageLocation, ) -> ProviderResult<()>

Source§

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

Source§

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

Source§

type Block = <T as BlockWriter>::Block

Source§

type Receipt = <T as BlockWriter>::Receipt

Source§

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

Source§

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

Source§

fn remove_blocks_above( &self, block: BlockNumber, remove_from: StorageLocation, ) -> ProviderResult<()>

Source§

fn remove_bodies_above( &self, block: BlockNumber, remove_from: StorageLocation, ) -> ProviderResult<()>

Source§

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

Source§

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

Source§

type Block = <T as BlockWriter>::Block

Source§

type Receipt = <T as BlockWriter>::Receipt

Source§

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

Source§

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

Source§

fn remove_blocks_above( &self, block: BlockNumber, remove_from: StorageLocation, ) -> ProviderResult<()>

Source§

fn remove_bodies_above( &self, block: BlockNumber, remove_from: StorageLocation, ) -> ProviderResult<()>

Source§

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

Implementors§

Source§

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

Source§

type Block = <<N as NodeTypes>::Primitives as NodePrimitives>::Block

Source§

type Receipt = <<N as NodeTypes>::Primitives as NodePrimitives>::Receipt