mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 20:27:58 +00:00
Make offchain worker calls more future proof. (#4618)
* Add warning if offchain workers version is not supported. * Support only v2. * Make it a warning.
This commit is contained in:
committed by
Bastian Köcher
parent
c5c73abc05
commit
e58fafc3ef
@@ -101,13 +101,14 @@ impl<Client, Storage, Block> OffchainWorkers<
|
||||
let has_api_v1 = runtime.has_api_with::<dyn OffchainWorkerApi<Block, Error = ()>, _>(
|
||||
&at, |v| v == 1
|
||||
);
|
||||
let has_api_v2 = runtime.has_api::<dyn OffchainWorkerApi<Block, Error = ()>>(&at);
|
||||
let has_api_v2 = runtime.has_api_with::<dyn OffchainWorkerApi<Block, Error = ()>, _>(
|
||||
&at, |v| v == 2
|
||||
);
|
||||
let version = match (has_api_v1, has_api_v2) {
|
||||
(_, Ok(true)) => 2,
|
||||
(Ok(true), _) => 1,
|
||||
_ => 0,
|
||||
};
|
||||
|
||||
debug!("Checking offchain workers at {:?}: version:{}", at, version);
|
||||
if version > 0 {
|
||||
let (api, runner) = api::AsyncApi::new(
|
||||
@@ -139,6 +140,8 @@ impl<Client, Storage, Block> OffchainWorkers<
|
||||
});
|
||||
futures::future::Either::Left(runner.process())
|
||||
} else {
|
||||
let help = "Consider turning off offchain workers if they are not part of your runtime.";
|
||||
log::error!("Unsupported Offchain Worker API version: {}. {}", version, help);
|
||||
futures::future::Either::Right(futures::future::ready(()))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user