Skip to content

Commit

Permalink
Solving issue of finalized meta after processed block
Browse files Browse the repository at this point in the history
  • Loading branch information
godmodegalactus committed Mar 22, 2024
1 parent 7035851 commit 1610681
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cluster-endpoints/src/grpc_multiplex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ pub fn create_grpc_multiplex_blocks_subscription(
let mut cleanup_without_confirmed_recv_blocks_meta: u32 = 0;
let mut cleanup_without_finalized_recv_blocks_meta: u32 = 0;
let mut confirmed_block_not_yet_processed = HashSet::<String>::new();
let mut finalized_block_not_yet_processed = HashSet::<String>::new();

// start logging errors when we recieve first finalized block
let mut startup_completed = false;
Expand All @@ -182,6 +183,11 @@ pub fn create_grpc_multiplex_blocks_subscription(
warn!("produced block channel has no receivers {e:?}");
}
}
if finalized_block_not_yet_processed.remove(&processed_block.blockhash) {
if let Err(e) = producedblock_sender.send(processed_block.to_finalized_block()) {
warn!("produced block channel has no receivers {e:?}");
}
}
recent_processed_blocks.insert(processed_block.blockhash.clone(), processed_block);
},
meta_confirmed = confirmed_blockmeta_stream.next() => {
Expand All @@ -206,6 +212,7 @@ pub fn create_grpc_multiplex_blocks_subscription(
let finalized_block = cached_processed_block.to_finalized_block();
last_finalized_slot = finalized_block.slot;
startup_completed = true;
log::info!("sending finalized block");
debug!("got finalized blockmeta {} with blockhash {}",
finalized_block.slot, finalized_block.blockhash.clone());
if let Err(e) = producedblock_sender.send(finalized_block) {
Expand All @@ -214,6 +221,7 @@ pub fn create_grpc_multiplex_blocks_subscription(
} else if startup_completed {
// this warning is ok for first few blocks when we start lrpc
log::warn!("finalized block meta received for blockhash {} which was never seen or already emitted", blockhash);
finalized_block_not_yet_processed.insert(blockhash);
}
},
_ = cleanup_tick.tick() => {
Expand Down

0 comments on commit 1610681

Please sign in to comment.