Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Make offchain worker calls more future proof. #4618

Merged
merged 3 commits into from
Jan 14, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions client/offchain/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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.";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Problem is that validators need the offchain api, otherwise they don't send the heartbeat transactions. So, turning it off is not the best idea?

log::error!("Unsupported Offchain Worker API version: {}. {}", version, help);
futures::future::Either::Right(futures::future::ready(()))
}
}
Expand Down