From 3d00992c95dd9eea2003f910f7bf50cdabb84817 Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Tue, 19 Feb 2019 21:19:27 -0800 Subject: [PATCH] Remove dependency on Entry::tick_height --- src/entry_stream_stage.rs | 13 ++++++++++--- src/tvu.rs | 1 + 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/entry_stream_stage.rs b/src/entry_stream_stage.rs index 0fc1c2f6ef..0029702402 100644 --- a/src/entry_stream_stage.rs +++ b/src/entry_stream_stage.rs @@ -26,6 +26,7 @@ impl EntryStreamStage { pub fn new( ledger_entry_receiver: EntryReceiver, entry_stream_socket: String, + mut tick_height: u64, leader_scheduler: Arc>, exit: Arc, ) -> (Self, EntryReceiver) { @@ -40,6 +41,7 @@ impl EntryStreamStage { if let Err(e) = Self::process_entries( &ledger_entry_receiver, &entry_stream_sender, + &mut tick_height, &mut entry_stream, ) { match e { @@ -55,6 +57,7 @@ impl EntryStreamStage { fn process_entries( ledger_entry_receiver: &EntryReceiver, entry_stream_sender: &EntrySender, + tick_height: &mut u64, entry_stream: &mut EntryStream, ) -> Result<()> { let timeout = Duration::new(1, 0); @@ -62,7 +65,10 @@ impl EntryStreamStage { let leader_scheduler = entry_stream.leader_scheduler.read().unwrap(); for entry in &entries { - let slot = leader_scheduler.tick_height_to_slot(entry.tick_height); + if entry.is_tick() { + *tick_height += 1 + } + let slot = leader_scheduler.tick_height_to_slot(*tick_height); let leader_id = leader_scheduler .get_leader_for_slot(slot) .map(|leader| leader.to_string()) @@ -85,10 +91,10 @@ impl EntryStreamStage { .unwrap_or_else(|e| { debug!("Entry Stream error: {:?}, {:?}", e, entry_stream.output); }); - if 0 == leader_scheduler.num_ticks_left_in_slot(entry.tick_height) { + if 0 == leader_scheduler.num_ticks_left_in_slot(*tick_height) { entry_stream.queued_block = Some(EntryStreamBlock { slot, - tick_height: entry.tick_height, + tick_height: *tick_height, id: entry.id, }); } @@ -158,6 +164,7 @@ mod test { EntryStreamStage::process_entries( &ledger_entry_receiver, &entry_stream_sender, + &mut 1, &mut entry_stream, ) .unwrap(); diff --git a/src/tvu.rs b/src/tvu.rs index 15a34974f0..83ee3a2019 100644 --- a/src/tvu.rs +++ b/src/tvu.rs @@ -139,6 +139,7 @@ impl Tvu { let (entry_stream_stage, entry_stream_receiver) = EntryStreamStage::new( previous_receiver, entry_stream.unwrap().to_string(), + bank.tick_height(), leader_scheduler, exit.clone(), );