Skip to content

Commit

Permalink
Move MIP info declaration in its own file
Browse files Browse the repository at this point in the history
  • Loading branch information
sydhds committed Jun 1, 2023
1 parent facb4d7 commit f15d2a7
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 22 deletions.
27 changes: 7 additions & 20 deletions massa-node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,14 @@ use massa_protocol_exports::{ProtocolConfig, ProtocolManager};
use massa_protocol_worker::{create_protocol_controller, start_protocol_controller};
use massa_storage::Storage;
use massa_time::MassaTime;
use massa_versioning::versioning::{MipComponent, MipInfo, MipState, MipStatsConfig, MipStore};
use massa_versioning::{
mips::MIP_LIST,
versioning::{MipStatsConfig, MipStore},
};
use massa_wallet::Wallet;
use parking_lot::RwLock;
use peernet::transports::TransportType;
use std::collections::{BTreeMap, HashMap};
use std::collections::HashMap;
use std::path::PathBuf;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::{Condvar, Mutex};
Expand Down Expand Up @@ -234,24 +237,8 @@ async fn launch(
block_count_considered: MIP_STORE_STATS_BLOCK_CONSIDERED,
counters_max: MIP_STORE_STATS_COUNTERS_MAX,
};
let mip_store = MipStore::try_from((
[(
MipInfo {
name: "MIP-0000".to_string(),
version: 0,
components: BTreeMap::from([
(MipComponent::Address, 0),
(MipComponent::KeyPair, 0),
]),
start: MassaTime::from_millis(0),
timeout: MassaTime::from_millis(0),
activation_delay: MassaTime::from_millis(0),
},
MipState::new(MassaTime::from_millis(0)),
)],
mip_stats_config,
))
.expect("mip store creation failed");
let mip_store =
MipStore::try_from((MIP_LIST, mip_stats_config)).expect("mip store creation failed");

// Create final state, either from a snapshot, or from scratch
let final_state = Arc::new(parking_lot::RwLock::new(
Expand Down
6 changes: 4 additions & 2 deletions massa-versioning/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
//! MIPState -> Deployment state of a MIPInfo
//! MIPStore -> A map of MIPInfo -> MipState
//!
//!
//! # Notes on MipInfo versions
//!
//! There is 2 different 'versions':
Expand All @@ -17,11 +18,11 @@
//!
//! # Notes on MipInfo timings and stats
//!
//! So in the execution module and after a block become final, we update the MipStore stats (in a blocking way) then continue one.
//! So in the execution module and after a block become final, we update the MipStore stats (in a blocking way).
//! By updating the stats, we mean sending: (Slot timestamp, Option<(current: u32, advertising: Option)>).
//! Using the slot timestamp, ensure that the trigger (and the trigger timeout) is a consensus by all nodes
//! (This means that the trigger and the trigger timeout are not timer based).
//! In order to have all nodes in sync (because of node various delays), the state is se to active
//! In order to have all nodes in sync (because of node various delays), the state is set to active
//! after an activation delay (duration is required to be > 1 cycle).
//!
//! # Notes on MipState
Expand Down Expand Up @@ -53,6 +54,7 @@
pub mod address_factory;
pub mod grpc_mapping;
pub mod keypair_factory;
pub mod mips;
pub mod versioning;
pub mod versioning_factory;
pub mod versioning_ser_der;
Expand Down
20 changes: 20 additions & 0 deletions massa-versioning/src/mips.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#[allow(unused_imports)]
use crate::versioning::{MipComponent, MipInfo, MipState};

pub const MIP_LIST: [(MipInfo, MipState); 0] = [
// MIP placeholder
/* (
MipInfo {
name: "MIP-0000".to_string(),
version: 0,
components: BTreeMap::from([
(MipComponent::Address, 0),
(MipComponent::KeyPair, 0),
]),
start: MassaTime::from_millis(0),
timeout: MassaTime::from_millis(0),
activation_delay: MassaTime::from_millis(0),
},
MipState::new(MassaTime::from_millis(0)),
) */
];

0 comments on commit f15d2a7

Please sign in to comment.