mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 18:41:05 +00:00
Add standalone set head operations (#1600)
* Refactor head setting operation to a separate function * Fix commit issue and implement set_head standalone in db * Add standalone set head operations * Address grumbles * Change number_and_hash_to_lookup key in light mod to take reference * Fix bug in set head commit * Add a convenience fn * Fix a deadlock * Fix missing argument
This commit is contained in:
@@ -650,6 +650,25 @@ impl<B, E, Block, RA> Client<B, E, Block, RA> where
|
||||
result
|
||||
}
|
||||
|
||||
/// Set a block as best block.
|
||||
pub fn set_head(
|
||||
&self,
|
||||
id: BlockId<Block>
|
||||
) -> error::Result<()> {
|
||||
self.lock_import_and_run(|operation| {
|
||||
self.apply_head(operation, id)
|
||||
})
|
||||
}
|
||||
|
||||
/// Set a block as best block, and apply it to an operation.
|
||||
pub fn apply_head(
|
||||
&self,
|
||||
operation: &mut ClientImportOperation<Block, Blake2Hasher, B>,
|
||||
id: BlockId<Block>,
|
||||
) -> error::Result<()> {
|
||||
operation.op.mark_head(id)
|
||||
}
|
||||
|
||||
/// Apply a checked and validated block to an operation. If a justification is provided
|
||||
/// then `finalized` *must* be true.
|
||||
pub fn apply_block(
|
||||
|
||||
Reference in New Issue
Block a user