mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 17:01:09 +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:
@@ -97,7 +97,7 @@ impl<Client, Storage, Block> OffchainWorkers<
|
||||
is_validator: bool,
|
||||
) -> impl Future<Output = ()> {
|
||||
let runtime = self.client.runtime_api();
|
||||
let at = BlockId::number(*header.number());
|
||||
let at = BlockId::hash(header.hash());
|
||||
let has_api_v1 = runtime.has_api_with::<dyn OffchainWorkerApi<Block, Error = ()>, _>(
|
||||
&at, |v| v == 1
|
||||
);
|
||||
@@ -169,7 +169,6 @@ mod tests {
|
||||
use substrate_test_runtime_client::runtime::Block;
|
||||
use sc_transaction_pool::{BasicPool, FullChainApi};
|
||||
use sp_transaction_pool::{TransactionPool, InPoolTransaction};
|
||||
use sp_runtime::{generic::Header, traits::Header as _};
|
||||
|
||||
struct MockNetworkStateInfo();
|
||||
|
||||
@@ -210,13 +209,7 @@ mod tests {
|
||||
.register_transaction_pool(Arc::downgrade(&pool.clone()) as _);
|
||||
let db = sc_client_db::offchain::LocalStorage::new_test();
|
||||
let network_state = Arc::new(MockNetworkStateInfo());
|
||||
let header = Header::new(
|
||||
0u64,
|
||||
Default::default(),
|
||||
Default::default(),
|
||||
Default::default(),
|
||||
Default::default(),
|
||||
);
|
||||
let header = client.header(&BlockId::number(0)).unwrap().unwrap();
|
||||
|
||||
// when
|
||||
let offchain = OffchainWorkers::new(client, db);
|
||||
|
||||
Reference in New Issue
Block a user