pub trait BlockWriter: Send + Sync {
type Body: Send + Sync;
// Required methods
fn insert_block(
&self,
block: SealedBlockWithSenders<Header, Self::Body>,
write_transactions_to: StorageLocation,
) -> Result<StoredBlockBodyIndices, ProviderError>;
fn append_block_bodies(
&self,
bodies: Vec<(u64, Option<Self::Body>)>,
write_transactions_to: StorageLocation,
) -> Result<(), ProviderError>;
fn remove_blocks_above(
&self,
block: u64,
remove_transactions_from: StorageLocation,
) -> Result<(), ProviderError>;
fn remove_bodies_above(
&self,
block: u64,
remove_transactions_from: StorageLocation,
) -> Result<(), ProviderError>;
fn append_blocks_with_state(
&self,
blocks: Vec<SealedBlockWithSenders<Header, Self::Body>>,
execution_outcome: ExecutionOutcome,
hashed_state: HashedPostStateSorted,
trie_updates: TrieUpdates,
) -> Result<(), ProviderError>;
}
Expand description
Block Writer
Required Associated Types§
Required Methods§
Sourcefn insert_block(
&self,
block: SealedBlockWithSenders<Header, Self::Body>,
write_transactions_to: StorageLocation,
) -> Result<StoredBlockBodyIndices, ProviderError>
fn insert_block( &self, block: SealedBlockWithSenders<Header, Self::Body>, write_transactions_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.
Sourcefn append_block_bodies(
&self,
bodies: Vec<(u64, Option<Self::Body>)>,
write_transactions_to: StorageLocation,
) -> Result<(), ProviderError>
fn append_block_bodies( &self, bodies: Vec<(u64, Option<Self::Body>)>, write_transactions_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 Option
s, if body is None
the corresponding block is empty.
Sourcefn remove_blocks_above(
&self,
block: u64,
remove_transactions_from: StorageLocation,
) -> Result<(), ProviderError>
fn remove_blocks_above( &self, block: u64, remove_transactions_from: StorageLocation, ) -> Result<(), ProviderError>
Removes all blocks above the given block number from the database.
Note: This does not remove state or execution data.
Sourcefn remove_bodies_above(
&self,
block: u64,
remove_transactions_from: StorageLocation,
) -> Result<(), ProviderError>
fn remove_bodies_above( &self, block: u64, remove_transactions_from: StorageLocation, ) -> Result<(), ProviderError>
Removes all block bodies above the given block number from the database.
Sourcefn append_blocks_with_state(
&self,
blocks: Vec<SealedBlockWithSenders<Header, Self::Body>>,
execution_outcome: ExecutionOutcome,
hashed_state: HashedPostStateSorted,
trie_updates: TrieUpdates,
) -> Result<(), ProviderError>
fn append_blocks_with_state( &self, blocks: Vec<SealedBlockWithSenders<Header, Self::Body>>, execution_outcome: ExecutionOutcome, 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 ofSealedBlockWithSenders
instances to append.state
: Post-state information to update after appending.
§Returns
Returns Ok(())
on success, or an error if any operation fails.