Announce block after it is being enacted as new best block (#182)

This commit is contained in:
Bastian Köcher
2020-08-06 20:37:36 +02:00
committed by GitHub
parent 3f3beea7f0
commit e8e8881a68
2 changed files with 11 additions and 2 deletions
+6 -1
View File
@@ -520,7 +520,12 @@ where
)));
let follow =
match cumulus_consensus::follow_polkadot(self.para_id, self.client, polkadot_client) {
match cumulus_consensus::follow_polkadot(
self.para_id,
self.client,
polkadot_client,
self.announce_block.clone(),
) {
Ok(follow) => follow,
Err(e) => {
return Err(error!("Could not start following polkadot: {:?}", e));
+5 -1
View File
@@ -104,6 +104,7 @@ pub fn follow_polkadot<L, P, Block, B>(
para_id: ParaId,
local: Arc<L>,
polkadot: P,
announce_block: Arc<dyn Fn(Block::Hash, Vec<u8>) + Send + Sync>,
) -> ClientResult<impl Future<Output = ()> + Send + Unpin>
where
Block: BlockT,
@@ -136,7 +137,7 @@ where
.map(|_| ())
};
Ok(future::select(follow_finalized, follow_new_best(para_id, local, polkadot)?).map(|_| ()))
Ok(future::select(follow_finalized, follow_new_best(para_id, local, polkadot, announce_block)?).map(|_| ()))
}
/// Follow the relay chain new best head, to update the Parachain new best head.
@@ -144,6 +145,7 @@ fn follow_new_best<L, P, Block, B>(
para_id: ParaId,
local: Arc<L>,
polkadot: P,
announce_block: Arc<dyn Fn(Block::Hash, Vec<u8>) + Send + Sync>,
) -> ClientResult<impl Future<Output = ()> + Send + Unpin>
where
Block: BlockT,
@@ -195,6 +197,8 @@ where
hash, err
);
}
(*announce_block)(hash, Vec::new());
}
Ok(BlockStatus::InChainPruned) => {
error!(