diff options
Diffstat (limited to 'src/remake/vote.rs')
| -rw-r--r-- | src/remake/vote.rs | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/src/remake/vote.rs b/src/remake/vote.rs index b4936dc..9e28cde 100644 --- a/src/remake/vote.rs +++ b/src/remake/vote.rs @@ -28,7 +28,7 @@ use tracing::{info, warn}; use super::Host; use super::content; -use super::records::{self, Decision, EpochRecord, Phase, Record, Register, Vote, unix_millis}; +use super::records::{self, Decision, EpochRecord, Phase, Record, Register, Vote}; use crate::document::store::StoreError; /// A majority of `electorate` members. @@ -235,19 +235,12 @@ pub(super) async fn cast<H: Host>(host: &H) { // Usually there is nothing to vote on: look first, without writing. let (voter, wanted) = (me.clone(), epoch.clone()); + let now = host.now_millis(); let due = host .read_doc(move |doc| { let all = records::load_all(doc); let register = records::load_register(doc); - let id = choice( - &voter, - &wanted, - &all, - ®ister, - started, - unix_millis(), - grace, - )?; + let id = choice(&voter, &wanted, &all, ®ister, started, now, grace)?; let content = all .into_iter() .find(|(other, _)| *other == id) @@ -267,9 +260,10 @@ pub(super) async fn cast<H: Host>(host: &H) { // Decided again under the write lock, so two passes can't both vote. let voter = me.clone(); + let clock = host.clock(); let result = host .commit_doc(move |doc| -> Result<Option<String>, StoreError> { - let now = unix_millis(); + let now = clock.now_millis(); let all = records::load_all(doc); let register = records::load_register(doc); let Some(id) = choice(&voter, &epoch, &all, ®ister, started, now, grace) |
