From 5c7d743883ef972b5c5e88a92493cefa5dfdb117 Mon Sep 17 00:00:00 2001 From: Tyera Eulberg Date: Wed, 26 Aug 2020 12:34:02 -0600 Subject: [PATCH] Timestamp first vote (#11856) --- core/src/consensus.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/src/consensus.rs b/core/src/consensus.rs index 1434296e56..7a3abae246 100644 --- a/core/src/consensus.rs +++ b/core/src/consensus.rs @@ -344,7 +344,9 @@ impl Tower { } fn maybe_timestamp(&mut self, current_slot: Slot) -> Option { - if current_slot > self.last_timestamp.slot { + if current_slot > self.last_timestamp.slot + || self.last_timestamp.slot == 0 && current_slot == self.last_timestamp.slot + { let timestamp = Utc::now().timestamp(); if timestamp >= self.last_timestamp.timestamp { self.last_timestamp = BlockTimestamp { @@ -1821,7 +1823,7 @@ pub mod test { #[test] fn test_maybe_timestamp() { let mut tower = Tower::default(); - assert!(tower.maybe_timestamp(0).is_none()); + assert!(tower.maybe_timestamp(0).is_some()); assert!(tower.maybe_timestamp(1).is_some()); assert!(tower.maybe_timestamp(0).is_none()); // Refuse to timestamp an older slot assert!(tower.maybe_timestamp(1).is_none()); // Refuse to timestamp the same slot twice