archive_mode is optional in grin.toml (#707)

default to None in grin.toml (which defaults to false)
add example config in grin.toml
This commit is contained in:
Antioch Peverell 2018-02-13 13:08:21 -05:00 committed by Ignotus Peverell
parent ebd801f14e
commit 6fb139670e
4 changed files with 21 additions and 10 deletions

View file

@ -42,13 +42,15 @@ db_root = ".grin"
# #
chain_type = "Testnet1" chain_type = "Testnet1"
#run the node in "full archive" mode (default is fast-sync, pruned node)
#archive_mode = false
#7 = Bit flags for FULL_NODE, this structure needs to be changed #7 = Bit flags for FULL_NODE, this structure needs to be changed
#internally to make it more configurable #internally to make it more configurable
capabilities = [7] capabilities = [7]
#skip waiting for sync on startup, (optional param, mostly for testing) #skip waiting for sync on startup, (optional param, mostly for testing)
#skip_sync_wait = true #skip_sync_wait = false
#The P2P server details (i.e. the server that communicates with other #The P2P server details (i.e. the server that communicates with other
#grin server nodes #grin server nodes

View file

@ -140,6 +140,15 @@ impl Server {
p2p_server.clone(), config.capabilities, seeder, stop.clone()); p2p_server.clone(), config.capabilities, seeder, stop.clone());
} }
// Defaults to None (optional) in config file.
// This translates to false here.
let archive_mode = match config.archive_mode {
None => false,
Some(b) => b,
};
// Defaults to None (optional) in config file.
// This translates to false here so we do not skip by default.
let skip_sync_wait = match config.skip_sync_wait { let skip_sync_wait = match config.skip_sync_wait {
None => false, None => false,
Some(b) => b, Some(b) => b,
@ -150,7 +159,7 @@ impl Server {
p2p_server.peers.clone(), p2p_server.peers.clone(),
shared_chain.clone(), shared_chain.clone(),
skip_sync_wait, skip_sync_wait,
!config.archive_mode, !archive_mode,
stop.clone(), stop.clone(),
); );

View file

@ -117,7 +117,7 @@ pub struct ServerConfig {
pub chain_type: ChainTypes, pub chain_type: ChainTypes,
/// Whether this node is a full archival node or a fast-sync, pruned node /// Whether this node is a full archival node or a fast-sync, pruned node
pub archive_mode: bool, pub archive_mode: Option<bool>,
/// Method used to get the list of seed nodes for initial bootstrap. /// Method used to get the list of seed nodes for initial bootstrap.
#[serde(default)] #[serde(default)]
@ -158,9 +158,9 @@ impl Default for ServerConfig {
p2p_config: p2p::P2PConfig::default(), p2p_config: p2p::P2PConfig::default(),
mining_config: Some(pow::types::MinerConfig::default()), mining_config: Some(pow::types::MinerConfig::default()),
chain_type: ChainTypes::default(), chain_type: ChainTypes::default(),
archive_mode: false, archive_mode: None,
pool_config: pool::PoolConfig::default(), pool_config: pool::PoolConfig::default(),
skip_sync_wait: Some(true), skip_sync_wait: None,
} }
} }
} }

View file

@ -269,7 +269,7 @@ fn simulate_fast_sync() {
thread::sleep(time::Duration::from_secs(8)); thread::sleep(time::Duration::from_secs(8));
let mut conf = config(1001, "grin-fast"); let mut conf = config(1001, "grin-fast");
conf.archive_mode = false; conf.archive_mode = Some(false);
conf.seeds = Some(vec!["127.0.0.1:12000".to_string()]); conf.seeds = Some(vec!["127.0.0.1:12000".to_string()]);
let s2 = grin::Server::new(conf).unwrap(); let s2 = grin::Server::new(conf).unwrap();
while s2.head().height != s2.header_head().height || s2.head().height < 20 { while s2.head().height != s2.header_head().height || s2.head().height < 20 {
@ -294,7 +294,7 @@ fn simulate_fast_sync_double() {
{ {
let mut conf = config(1001, "grin-double-fast2"); let mut conf = config(1001, "grin-double-fast2");
conf.archive_mode = false; conf.archive_mode = Some(false);
conf.seeds = Some(vec!["127.0.0.1:12000".to_string()]); conf.seeds = Some(vec!["127.0.0.1:12000".to_string()]);
let s2 = grin::Server::new(conf).unwrap(); let s2 = grin::Server::new(conf).unwrap();
while s2.head().height != s2.header_head().height || s2.head().height < 20 { while s2.head().height != s2.header_head().height || s2.head().height < 20 {
@ -308,7 +308,7 @@ fn simulate_fast_sync_double() {
thread::sleep(time::Duration::from_secs(20)); thread::sleep(time::Duration::from_secs(20));
let mut conf = config(1001, "grin-double-fast2"); let mut conf = config(1001, "grin-double-fast2");
conf.archive_mode = false; conf.archive_mode = Some(false);
conf.seeds = Some(vec!["127.0.0.1:12000".to_string()]); conf.seeds = Some(vec!["127.0.0.1:12000".to_string()]);
let s2 = grin::Server::new(conf).unwrap(); let s2 = grin::Server::new(conf).unwrap();
while s2.head().height != s2.header_head().height || s2.head().height < 50 { while s2.head().height != s2.header_head().height || s2.head().height < 50 {
@ -327,7 +327,7 @@ fn config(n: u16, test_name_dir: &str) -> grin::ServerConfig {
seeding_type: grin::Seeding::List, seeding_type: grin::Seeding::List,
seeds: Some(vec!["127.0.0.1:11000".to_string()]), seeds: Some(vec!["127.0.0.1:11000".to_string()]),
chain_type: core::global::ChainTypes::AutomatedTesting, chain_type: core::global::ChainTypes::AutomatedTesting,
archive_mode: true, archive_mode: Some(true),
skip_sync_wait: Some(true), skip_sync_wait: Some(true),
..Default::default() ..Default::default()
} }