diff --git a/poh/src/poh_recorder.rs b/poh/src/poh_recorder.rs index 9d020f49a9c5d5..8755cea068505c 100644 --- a/poh/src/poh_recorder.rs +++ b/poh/src/poh_recorder.rs @@ -191,6 +191,7 @@ pub struct WorkingBank { pub start: Arc, pub min_tick_height: u64, pub max_tick_height: u64, + pub transaction_index: usize, } #[derive(Debug, PartialEq, Eq)] @@ -501,6 +502,7 @@ impl PohRecorder { start: Arc::new(Instant::now()), min_tick_height: bank.tick_height(), max_tick_height: bank.max_tick_height(), + transaction_index: 0, }; trace!("new working bank"); assert_eq!(working_bank.bank.ticks_per_slot(), self.ticks_per_slot()); @@ -756,9 +758,9 @@ impl PohRecorder { self.flush_cache_no_tick_us += flush_cache_time.as_us(); flush_cache_res?; - let working_bank = self + let mut working_bank = self .working_bank - .as_ref() + .as_mut() .ok_or(PohRecorderError::MaxHeightReached)?; if bank_slot != working_bank.bank.slot() { return Err(PohRecorderError::MaxHeightReached); @@ -774,6 +776,7 @@ impl PohRecorder { drop(poh_lock); if let Some(poh_entry) = record_mixin_res { + let num_transactions = transactions.len(); let (send_entry_res, send_entry_time) = measure!( { let entry = Entry { @@ -788,7 +791,14 @@ impl PohRecorder { ); self.send_entry_us += send_entry_time.as_us(); send_entry_res?; - return Ok(vec![]); + let transaction_index_next_batch = working_bank + .transaction_index + .saturating_add(num_transactions); + let transaction_indexes: Vec<_> = + (working_bank.transaction_index..transaction_index_next_batch).collect(); + working_bank.transaction_index = transaction_index_next_batch; + self.working_bank = Some(working_bank.clone()); + return Ok(transaction_indexes); } // record() might fail if the next PoH hash needs to be a tick. But that's ok, tick()