ab_client_informer/
lib.rs1use ab_client_api::ChainInfo;
4use ab_core_primitives::block::header::GenericBlockHeader;
5use ab_core_primitives::block::header::owned::GenericOwnedBlockHeader;
6use ab_core_primitives::block::owned::GenericOwnedBlock;
7use ab_core_primitives::shard::RealShardKind;
8use std::time::Duration;
9use tracing::info;
10
11pub async fn run_informer<Block, CI>(chain_info: &CI, log_interval: Duration)
12where
13 Block: GenericOwnedBlock,
14 CI: ChainInfo<Block>,
15{
16 let shard = match Block::SHARD_KIND {
17 RealShardKind::BeaconChain => "BeaconChain".to_string(),
18 RealShardKind::IntermediateShard => {
19 format!(
20 "Intermediate[{}]",
21 u32::from(chain_info.best_header().header().prefix.shard_index)
22 )
23 }
24 RealShardKind::LeafShard => {
25 format!(
26 "Leaf[{}]",
27 u32::from(chain_info.best_header().header().prefix.shard_index)
28 )
29 }
30 };
31 #[expect(
32 clippy::infinite_loop,
33 reason = "Intentional loop is a part of a future that can be dropped"
34 )]
35 loop {
36 let best_header = chain_info.best_header();
39 info!(
40 %shard,
41 best_number = %best_header.header().prefix.number,
42 best_root = %*best_header.header().root(),
43 "💤"
44 );
45
46 tokio::time::sleep(log_interval).await;
47 }
48}