From e58fafc3ef8cbcbb1bb64bf87f9dbc6a01c0abdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Tue, 14 Jan 2020 22:35:35 +0100 Subject: [PATCH] Make offchain worker calls more future proof. (#4618) * Add warning if offchain workers version is not supported. * Support only v2. * Make it a warning. --- substrate/client/offchain/src/lib.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/substrate/client/offchain/src/lib.rs b/substrate/client/offchain/src/lib.rs index e25072d42d..78760fb011 100644 --- a/substrate/client/offchain/src/lib.rs +++ b/substrate/client/offchain/src/lib.rs @@ -101,13 +101,14 @@ impl OffchainWorkers< let has_api_v1 = runtime.has_api_with::, _>( &at, |v| v == 1 ); - let has_api_v2 = runtime.has_api::>(&at); + let has_api_v2 = runtime.has_api_with::, _>( + &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 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(())) } }