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:
Tomasz Drwięga
2020-02-11 00:41:59 +01:00
committed by GitHub
parent ef7d19ed93
commit 05b3e1f654
4 changed files with 30 additions and 23 deletions
+18 -10
View File
@@ -898,16 +898,24 @@ ServiceBuilder<
}
let offchain = offchain.as_ref().and_then(|o| o.upgrade());
if let Some(offchain) = offchain {
let future = offchain.on_block_imported(
&notification.header,
network_state_info.clone(),
is_validator
);
let _ = to_spawn_tx_.unbounded_send((
Box::pin(future),
From::from("offchain-on-block")
));
match offchain {
Some(offchain) if notification.is_new_best => {
let future = offchain.on_block_imported(
&notification.header,
network_state_info.clone(),
is_validator,
);
let _ = to_spawn_tx_.unbounded_send((
Box::pin(future),
From::from("offchain-on-block"),
));
},
Some(_) => log::debug!(
target: "sc_offchain",
"Skipping offchain workers for non-canon block: {:?}",
notification.header,
),
_ => {},
}
ready(())