From d0086587886a872e80b4a80f1cd0e711fc204d2d Mon Sep 17 00:00:00 2001 From: sydhds Date: Mon, 27 Jan 2025 16:56:48 +0100 Subject: [PATCH] Add more documentation --- massa-versioning/src/lib.rs | 4 +- massa-versioning/src/versioning.rs | 78 +++++++++++++++--------------- 2 files changed, 42 insertions(+), 40 deletions(-) diff --git a/massa-versioning/src/lib.rs b/massa-versioning/src/lib.rs index 226328c5a4..fccfb12c58 100644 --- a/massa-versioning/src/lib.rs +++ b/massa-versioning/src/lib.rs @@ -3,7 +3,8 @@ //! # General description //! MIP = Massa Improvement proposal (similar to Bitcoin Improvement Proposal - BIP or Ethereum - EIP) //! -//! MIPInfo -> represent a MIP (name, versions, time ranges) +//! MipComponent -> A component that is going to be updated (e.g. Address v2) +//! MIPInfo -> represent a MIP (name, versions, time ranges, components) //! MIPState -> Deployment state of a MIPInfo //! MIPStore -> A map of MIPInfo -> MipState //! @@ -45,6 +46,7 @@ //! //! MipState has: //! * A state machine (stores the current state of deployment for a MipInfo) +//! * Usual state changes: Defined -> Started -> LockedIn -> Active //! * A history (stores a list of `Advance` message that 'really' updated the state machine) //! //! An auto generated graph of the state machine can be found here: diff --git a/massa-versioning/src/versioning.rs b/massa-versioning/src/versioning.rs index 3ad7274552..3ac025ba8f 100644 --- a/massa-versioning/src/versioning.rs +++ b/massa-versioning/src/versioning.rs @@ -198,44 +198,6 @@ impl PartialEq for Advance { impl Eq for Advance {} -// A Lightweight version of 'Advance' (used in MipState history) -#[derive(Clone, Debug)] -pub struct AdvanceLW { - /// % of past blocks with this version - pub threshold: Ratio, - /// Current time (timestamp) - pub now: MassaTime, -} - -impl From<&Advance> for AdvanceLW { - fn from(value: &Advance) -> Self { - Self { - threshold: value.threshold, - now: value.now, - } - } -} - -impl Ord for AdvanceLW { - fn cmp(&self, other: &Self) -> Ordering { - (self.now, self.threshold).cmp(&(other.now, other.threshold)) - } -} - -impl PartialOrd for AdvanceLW { - fn partial_cmp(&self, other: &Self) -> Option { - Some(self.cmp(other)) - } -} - -impl PartialEq for AdvanceLW { - fn eq(&self, other: &Self) -> bool { - self.threshold == other.threshold && self.now == other.now - } -} - -impl Eq for AdvanceLW {} - transitions!(ComponentState, [ (Defined, Advance) => [Defined, Started, Failed], @@ -299,6 +261,44 @@ impl Failed { } } +// A Lightweight version of 'Advance' (used in MipState history) +#[derive(Clone, Debug)] +pub struct AdvanceLW { + /// % of past blocks with this version + pub threshold: Ratio, + /// Current time (timestamp) + pub now: MassaTime, +} + +impl From<&Advance> for AdvanceLW { + fn from(value: &Advance) -> Self { + Self { + threshold: value.threshold, + now: value.now, + } + } +} + +impl Ord for AdvanceLW { + fn cmp(&self, other: &Self) -> Ordering { + (self.now, self.threshold).cmp(&(other.now, other.threshold)) + } +} + +impl PartialOrd for AdvanceLW { + fn partial_cmp(&self, other: &Self) -> Option { + Some(self.cmp(other)) + } +} + +impl PartialEq for AdvanceLW { + fn eq(&self, other: &Self) -> bool { + self.threshold == other.threshold && self.now == other.now + } +} + +impl Eq for AdvanceLW {} + /// Error returned by `MipState::is_consistent_with` #[derive(Error, Debug, PartialEq)] pub enum IsConsistentError { @@ -1170,7 +1170,7 @@ impl MipStoreRaw { // Network restart /// Check if store is consistent with given last network shutdown - /// On a network shutdown, the MIP infos will be edited but we still need to check if this is consistent + /// On a network shutdown, the MIP infos will be edited, but we still need to check if this is consistent fn is_consistent_with_shutdown_period( &self, shutdown_start: Slot,