-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
9 changed files
with
484 additions
and
131 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
use log::{debug, warn}; | ||
use solana_lite_rpc_core::types::BlockStream; | ||
use solana_sdk::commitment_config::CommitmentConfig; | ||
use tokio::sync::broadcast::error::RecvError; | ||
use tokio::task::JoinHandle; | ||
|
||
pub fn block_debug_listen( | ||
mut block_notifier: BlockStream, | ||
commitment_config: CommitmentConfig, | ||
) -> JoinHandle<()> { | ||
tokio::spawn(async move { | ||
let mut last_highest_slot_number = 0; | ||
|
||
loop { | ||
match block_notifier.recv().await { | ||
Ok(block) => { | ||
if block.commitment_config != commitment_config { | ||
continue; | ||
} | ||
|
||
debug!( | ||
"Saw block: {} @ {} with {} txs", | ||
block.slot, | ||
block.commitment_config.commitment, | ||
block.transactions.len() | ||
); | ||
|
||
if last_highest_slot_number != 0 { | ||
if block.parent_slot == last_highest_slot_number { | ||
debug!( | ||
"parent slot is correct ({} -> {})", | ||
block.slot, block.parent_slot | ||
); | ||
} else { | ||
warn!( | ||
"parent slot not correct ({} -> {})", | ||
block.slot, block.parent_slot | ||
); | ||
} | ||
} | ||
|
||
if block.slot > last_highest_slot_number { | ||
last_highest_slot_number = block.slot; | ||
} else { | ||
// note: ATM this fails very often (using the RPC poller) | ||
warn!( | ||
"Monotonic check failed - block {} is out of order, last highest was {}", | ||
block.slot, last_highest_slot_number | ||
); | ||
} | ||
} // -- Ok | ||
Err(RecvError::Lagged(missed_blocks)) => { | ||
warn!( | ||
"Could not keep up with producer - missed {} blocks", | ||
missed_blocks | ||
); | ||
} | ||
Err(other_err) => { | ||
panic!("Error receiving block: {:?}", other_err); | ||
} | ||
} | ||
|
||
// ... | ||
} | ||
}) | ||
} |
Oops, something went wrong.