pub trait BlockImportOperation<Block: BlockT> {
type State: StateBackend<HashingFor<Block>>;
// Required methods
fn state(&self) -> Result<Option<&Self::State>>;
fn set_block_data(
&mut self,
header: Block::Header,
body: Option<Vec<Block::Extrinsic>>,
indexed_body: Option<Vec<Vec<u8>>>,
justifications: Option<Justifications>,
state: NewBlockState,
) -> Result<()>;
fn update_db_storage(
&mut self,
update: BackendTransaction<HashingFor<Block>>,
) -> Result<()>;
fn set_genesis_state(
&mut self,
storage: Storage,
commit: bool,
state_version: StateVersion,
) -> Result<Block::Hash>;
fn reset_storage(
&mut self,
storage: Storage,
state_version: StateVersion,
) -> Result<Block::Hash>;
fn update_storage(
&mut self,
update: StorageCollection,
child_update: ChildStorageCollection,
) -> Result<()>;
fn insert_aux<I>(&mut self, ops: I) -> Result<()>
where I: IntoIterator<Item = (Vec<u8>, Option<Vec<u8>>)>;
fn mark_finalized(
&mut self,
hash: Block::Hash,
justification: Option<Justification>,
) -> Result<()>;
fn mark_head(&mut self, hash: Block::Hash) -> Result<()>;
fn update_transaction_index(
&mut self,
index: Vec<IndexOperation>,
) -> Result<()>;
fn set_create_gap(&mut self, create_gap: bool);
// Provided method
fn update_offchain_storage(
&mut self,
_offchain_update: OffchainChangesCollection,
) -> Result<()> { ... }
}
Expand description
Block insertion operation.
Keeps hold if the inserted block state and data.
Required Associated Types§
Sourcetype State: StateBackend<HashingFor<Block>>
type State: StateBackend<HashingFor<Block>>
Associated state backend type.
Required Methods§
Sourcefn state(&self) -> Result<Option<&Self::State>>
fn state(&self) -> Result<Option<&Self::State>>
Returns pending state.
Returns None for backends with locally-unavailable state data.
Sourcefn set_block_data(
&mut self,
header: Block::Header,
body: Option<Vec<Block::Extrinsic>>,
indexed_body: Option<Vec<Vec<u8>>>,
justifications: Option<Justifications>,
state: NewBlockState,
) -> Result<()>
fn set_block_data( &mut self, header: Block::Header, body: Option<Vec<Block::Extrinsic>>, indexed_body: Option<Vec<Vec<u8>>>, justifications: Option<Justifications>, state: NewBlockState, ) -> Result<()>
Append block data to the transaction.
Sourcefn update_db_storage(
&mut self,
update: BackendTransaction<HashingFor<Block>>,
) -> Result<()>
fn update_db_storage( &mut self, update: BackendTransaction<HashingFor<Block>>, ) -> Result<()>
Inject storage data into the database.
Sourcefn set_genesis_state(
&mut self,
storage: Storage,
commit: bool,
state_version: StateVersion,
) -> Result<Block::Hash>
fn set_genesis_state( &mut self, storage: Storage, commit: bool, state_version: StateVersion, ) -> Result<Block::Hash>
Set genesis state. If commit
is false
the state is saved in memory, but is not written
to the database.
Sourcefn reset_storage(
&mut self,
storage: Storage,
state_version: StateVersion,
) -> Result<Block::Hash>
fn reset_storage( &mut self, storage: Storage, state_version: StateVersion, ) -> Result<Block::Hash>
Inject storage data into the database replacing any existing data.
Sourcefn update_storage(
&mut self,
update: StorageCollection,
child_update: ChildStorageCollection,
) -> Result<()>
fn update_storage( &mut self, update: StorageCollection, child_update: ChildStorageCollection, ) -> Result<()>
Set storage changes.
Sourcefn insert_aux<I>(&mut self, ops: I) -> Result<()>
fn insert_aux<I>(&mut self, ops: I) -> Result<()>
Insert auxiliary keys.
Values are None
if should be deleted.
Sourcefn mark_finalized(
&mut self,
hash: Block::Hash,
justification: Option<Justification>,
) -> Result<()>
fn mark_finalized( &mut self, hash: Block::Hash, justification: Option<Justification>, ) -> Result<()>
Mark a block as finalized, if multiple blocks are finalized in the same operation then they must be marked in ascending order.
Sourcefn mark_head(&mut self, hash: Block::Hash) -> Result<()>
fn mark_head(&mut self, hash: Block::Hash) -> Result<()>
Mark a block as new head. If both block import and set head are specified, set head overrides block import’s best block rule.
Sourcefn update_transaction_index(&mut self, index: Vec<IndexOperation>) -> Result<()>
fn update_transaction_index(&mut self, index: Vec<IndexOperation>) -> Result<()>
Add a transaction index operation.
Sourcefn set_create_gap(&mut self, create_gap: bool)
fn set_create_gap(&mut self, create_gap: bool)
Configure whether to create a block gap if newly imported block is missing parent
Provided Methods§
Sourcefn update_offchain_storage(
&mut self,
_offchain_update: OffchainChangesCollection,
) -> Result<()>
fn update_offchain_storage( &mut self, _offchain_update: OffchainChangesCollection, ) -> Result<()>
Write offchain storage changes to the database.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.