mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 18:41:03 +00:00
Announce block after it is being enacted as new best block (#182)
This commit is contained in:
@@ -520,7 +520,12 @@ where
|
|||||||
)));
|
)));
|
||||||
|
|
||||||
let follow =
|
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,
|
Ok(follow) => follow,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
return Err(error!("Could not start following polkadot: {:?}", e));
|
return Err(error!("Could not start following polkadot: {:?}", e));
|
||||||
|
|||||||
@@ -104,6 +104,7 @@ pub fn follow_polkadot<L, P, Block, B>(
|
|||||||
para_id: ParaId,
|
para_id: ParaId,
|
||||||
local: Arc<L>,
|
local: Arc<L>,
|
||||||
polkadot: P,
|
polkadot: P,
|
||||||
|
announce_block: Arc<dyn Fn(Block::Hash, Vec<u8>) + Send + Sync>,
|
||||||
) -> ClientResult<impl Future<Output = ()> + Send + Unpin>
|
) -> ClientResult<impl Future<Output = ()> + Send + Unpin>
|
||||||
where
|
where
|
||||||
Block: BlockT,
|
Block: BlockT,
|
||||||
@@ -136,7 +137,7 @@ where
|
|||||||
.map(|_| ())
|
.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.
|
/// 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,
|
para_id: ParaId,
|
||||||
local: Arc<L>,
|
local: Arc<L>,
|
||||||
polkadot: P,
|
polkadot: P,
|
||||||
|
announce_block: Arc<dyn Fn(Block::Hash, Vec<u8>) + Send + Sync>,
|
||||||
) -> ClientResult<impl Future<Output = ()> + Send + Unpin>
|
) -> ClientResult<impl Future<Output = ()> + Send + Unpin>
|
||||||
where
|
where
|
||||||
Block: BlockT,
|
Block: BlockT,
|
||||||
@@ -195,6 +197,8 @@ where
|
|||||||
hash, err
|
hash, err
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
(*announce_block)(hash, Vec::new());
|
||||||
}
|
}
|
||||||
Ok(BlockStatus::InChainPruned) => {
|
Ok(BlockStatus::InChainPruned) => {
|
||||||
error!(
|
error!(
|
||||||
|
|||||||
Reference in New Issue
Block a user