Fix typos and a small refactor (#23805)

* fix typo

* remove packet_has_more_unprocessed_transactions function
This commit is contained in:
HaoranYi
2022-03-21 18:35:31 -05:00
committed by GitHub
parent c4ecfa5716
commit 45a7c6edfb

View File

@ -1,5 +1,5 @@
//! The `banking_stage` processes Transaction messages. It is intended to be used //! The `banking_stage` processes Transaction messages. It is intended to be used
//! to contruct a software pipeline. The stage uses all available CPU cores and //! to construct a software pipeline. The stage uses all available CPU cores and
//! can do its processing in parallel with signature verification on the GPU. //! can do its processing in parallel with signature verification on the GPU.
use { use {
crate::{ crate::{
@ -194,7 +194,7 @@ impl BankingStageStats {
} }
fn report(&mut self, report_interval_ms: u64) { fn report(&mut self, report_interval_ms: u64) {
// skip repoting metrics if stats is empty // skip reporting metrics if stats is empty
if self.is_empty() { if self.is_empty() {
return; return;
} }
@ -700,14 +700,11 @@ impl BankingStage {
// `original_unprocessed_indexes` must have remaining packets to process // `original_unprocessed_indexes` must have remaining packets to process
// if not yet processed. // if not yet processed.
assert!(Self::packet_has_more_unprocessed_transactions( assert!(!original_unprocessed_indexes.is_empty());
&original_unprocessed_indexes
));
true true
} }
} }
}); });
proc_start.stop(); proc_start.stop();
debug!( debug!(
@ -2015,7 +2012,7 @@ impl BankingStage {
banking_stage_stats: &mut BankingStageStats, banking_stage_stats: &mut BankingStageStats,
slot_metrics_tracker: &mut LeaderSlotMetricsTracker, slot_metrics_tracker: &mut LeaderSlotMetricsTracker,
) { ) {
if Self::packet_has_more_unprocessed_transactions(&packet_indexes) { if !packet_indexes.is_empty() {
if unprocessed_packet_batches.len() >= batch_limit { if unprocessed_packet_batches.len() >= batch_limit {
*dropped_packet_batches_count += 1; *dropped_packet_batches_count += 1;
if let Some(dropped_batch) = unprocessed_packet_batches.pop_front() { if let Some(dropped_batch) = unprocessed_packet_batches.pop_front() {
@ -2041,10 +2038,6 @@ impl BankingStage {
} }
} }
fn packet_has_more_unprocessed_transactions(packet_indexes: &[usize]) -> bool {
!packet_indexes.is_empty()
}
pub fn join(self) -> thread::Result<()> { pub fn join(self) -> thread::Result<()> {
for bank_thread_hdl in self.bank_thread_hdls { for bank_thread_hdl in self.bank_thread_hdls {
bank_thread_hdl.join()?; bank_thread_hdl.join()?;