mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 19:21:13 +00:00
Run offchain workers at hash, not number. (#4878)
* Run offchain workers at particular hash, not number. * Don't run if not new best. * Don't run if not new best. * Update client/service/src/builder.rs Co-Authored-By: Nikolay Volf <nikvolf@gmail.com> * Update client/service/src/builder.rs Co-Authored-By: Nikolay Volf <nikvolf@gmail.com> * Update client/service/src/builder.rs Co-authored-by: Nikolay Volf <nikvolf@gmail.com>
This commit is contained in:
@@ -59,19 +59,23 @@ pub trait HeaderBackend<Block: BlockT>: Send + Sync {
|
||||
|
||||
/// Get block header. Returns `UnknownBlock` error if block is not found.
|
||||
fn expect_header(&self, id: BlockId<Block>) -> Result<Block::Header> {
|
||||
self.header(id)?.ok_or_else(|| Error::UnknownBlock(format!("{}", id)))
|
||||
self.header(id)?.ok_or_else(|| Error::UnknownBlock(format!("Expect header: {}", id)))
|
||||
}
|
||||
|
||||
/// Convert an arbitrary block ID into a block number. Returns `UnknownBlock` error if block is not found.
|
||||
fn expect_block_number_from_id(&self, id: &BlockId<Block>) -> Result<NumberFor<Block>> {
|
||||
self.block_number_from_id(id)
|
||||
.and_then(|n| n.ok_or_else(|| Error::UnknownBlock(format!("{}", id))))
|
||||
.and_then(|n| n.ok_or_else(||
|
||||
Error::UnknownBlock(format!("Expect block number from id: {}", id))
|
||||
))
|
||||
}
|
||||
|
||||
/// Convert an arbitrary block ID into a block hash. Returns `UnknownBlock` error if block is not found.
|
||||
fn expect_block_hash_from_id(&self, id: &BlockId<Block>) -> Result<Block::Hash> {
|
||||
self.block_hash_from_id(id)
|
||||
.and_then(|n| n.ok_or_else(|| Error::UnknownBlock(format!("{}", id))))
|
||||
.and_then(|n| n.ok_or_else(||
|
||||
Error::UnknownBlock(format!("Expect block hash from id: {}", id))
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user