memoryd: sync begins when Honcho is turned on, and conclusions are matched by peer
Co-Authored-By: ornith-1.5-35b-a3b <agent@wntrmute.dev>
This commit is contained in:
@@ -3,12 +3,12 @@
|
||||
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use bxcore::SessionId;
|
||||
use bxcore::{SessionId, Timestamp};
|
||||
|
||||
use crate::config::Config;
|
||||
use crate::honcho::client::{Clients, Timeouts};
|
||||
use crate::honcho::config::HonchoConfig;
|
||||
use crate::honcho::ledger::Ledger;
|
||||
use crate::honcho::ledger::{Ledger, Record};
|
||||
use crate::honcho::mirror::Mirror;
|
||||
use crate::honcho::state;
|
||||
use crate::honcho::turns::{LEDGER, TurnSync};
|
||||
@@ -25,6 +25,20 @@ pub struct Opened {
|
||||
}
|
||||
|
||||
impl Opened {
|
||||
/// The first time: sync begins now. The `Began` line is written and synced once `memory/`
|
||||
/// exists and before any socket is bound, so every turn reported later is after it.
|
||||
pub fn begin(&self) -> Result<(), StartError> {
|
||||
let sync = self.sync.lock().unwrap_or_else(|p| p.into_inner());
|
||||
let mut ledger = sync.ledger();
|
||||
if ledger.began().is_none() {
|
||||
let began = Record::Began {
|
||||
time: Timestamp::now(),
|
||||
};
|
||||
ledger.append(began).map_err(StartError::Ledger)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// The memory writes' side of the ledger (task 12).
|
||||
pub fn mirror(&self) -> Mirror {
|
||||
let ledger = self
|
||||
|
||||
Reference in New Issue
Block a user