pub fn snapshot(
        &mut self,
        compact_idx: Option<u64>,
        local_only: bool,
    ) -> Result<(), CompactionErr> {
        let decided_idx = self.storage.get_decided_idx();
        let idx = match compact_idx {
            Some(i) => {
                if i <= decided_idx {
                    i
                } else {
                    return Err(CompactionErr::UndecidedIndex(decided_idx));
                }
            }
            None => decided_idx,
        };
        if idx > self.get_compacted_idx() {
            let snapshot = self.create_snapshot(idx);
            self.set_snapshot(idx, snapshot);
        }
        if !local_only {
            // since it is decided, it is ok even for a follower to send this
            for pid in &self.peers {
                let msg = PaxosMsg::Compaction(Compaction::Snapshot(idx));
                self.outgoing.push(Message::with(self.pid, *pid, msg));
            }
        }
        Ok(())
    }
/// Trim the log and create a snapshot. ** Note: only up to the `decided_idx` can be snapshotted **
/// # Arguments
/// `compact_idx` - Snapshots all entries < [`trim_index`], if the [`trim_index`] is None then the decided index will be used.
/// `local_only` - If `true`, only this server snapshots the log. If `false` all servers performs the snapshot.
Trim the log and create a snapshot. ** Note: only up to the `decided_idx` can be snapshotted
Trim the log and create a snapshot . ** Note : only up to the ` decided_idx ` can be snapshotted
pub fn snapshot(
        &mut self,
        compact_idx: Option<u64>,
        local_only: bool,
    ) -> Result<(), CompactionErr> {
        let decided_idx = self.storage.get_decided_idx();
        let idx = match compact_idx {
            Some(i) => {
                if i <= decided_idx {
                    i
                } else {
                    return Err(CompactionErr::UndecidedIndex(decided_idx));
                }
            }
            None => decided_idx,
        };
        if idx > self.get_compacted_idx() {
            let snapshot = self.create_snapshot(idx);
            self.set_snapshot(idx, snapshot);
        }
        if !local_only {
            // since it is decided, it is ok even for a follower to send this
            for pid in &self.peers {
                let msg = PaxosMsg::Compaction(Compaction::Snapshot(idx));
                self.outgoing.push(Message::with(self.pid, *pid, msg));
            }
        }
        Ok(())
    }
pub fn snapshot ( & mut self , compact_idx : Option < u64 > , local_only : bool , ) -> Result < ( ) , CompactionErr > { let decided_idx = self . storage . get_decided_idx ( ) ; let idx = match compact_idx { Some ( i ) => { if i <= decided_idx { i } else { return Err ( CompactionErr :: UndecidedIndex ( decided_idx ) ) ; } } None => decided_idx , } ; if idx > self . get_compacted_idx ( ) { let snapshot = self . create_snapshot ( idx ) ; self . set_snapshot ( idx , snapshot ) ; } if ! local_only { // since it is decided, it is ok even for a follower to send this for pid in & self . peers { let msg = PaxosMsg :: Compaction ( Compaction :: Snapshot ( idx ) ) ; self . outgoing . push ( Message :: with ( self . pid , * pid , msg ) ) ; } } Ok ( ( ) ) }
Trim the log and create a snapshot.
Trim the log and create a snapshot .
&mut self
compact_idx
Option<u64>
local_only
bool
&mut self
compact_idx
Option<u64>
local_only
bool