Default value for ChainType, when not in grin.toml

This commit is contained in:
Ignotus Peverell 2017-11-15 17:30:48 -05:00
parent 91fdaa8320
commit 97d7a43ccf
No known key found for this signature in database
GPG key ID: 99CD25F39F8F8211
4 changed files with 12 additions and 7 deletions

View file

@ -64,6 +64,12 @@ pub enum ChainTypes {
Mainnet,
}
impl Default for ChainTypes {
fn default() -> ChainTypes {
ChainTypes::UserTesting
}
}
lazy_static!{
/// The mining parameter mode
pub static ref CHAIN_TYPE: RwLock<ChainTypes> =

View file

@ -91,7 +91,7 @@ impl Server {
let mut genesis_block = None;
if !chain::Chain::chain_exists(config.db_root.clone()) {
let chain_type = config.chain_type.clone().unwrap();
let chain_type = config.chain_type.clone();
if chain_type == global::ChainTypes::Testnet1 {
genesis_block = Some(genesis::genesis_testnet1());
} else {

View file

@ -92,7 +92,8 @@ pub struct ServerConfig {
pub api_http_addr: String,
/// Setup the server for tests, testnet or mainnet
pub chain_type: Option<ChainTypes>,
#[serde(default)]
pub chain_type: ChainTypes,
/// Method used to get the list of seed nodes for initial bootstrap.
pub seeding_type: Seeding,
@ -125,7 +126,7 @@ impl Default for ServerConfig {
seeds: None,
p2p_config: Some(p2p::P2PConfig::default()),
mining_config: Some(pow::types::MinerConfig::default()),
chain_type: Some(ChainTypes::Testnet1),
chain_type: ChainTypes::default(),
pool_config: pool::PoolConfig::default(),
}
}

View file

@ -57,8 +57,7 @@ fn start_from_config_file(mut global_config: GlobalConfig) {
.unwrap()
.server
.clone()
.chain_type
.unwrap(),
.chain_type,
);
grin::Server::start(global_config.members.as_mut().unwrap().server.clone()).unwrap();
@ -102,8 +101,7 @@ fn main() {
.unwrap()
.server
.clone()
.chain_type
.unwrap(),
.chain_type,
);
} else {
init_logger(Some(LoggingConfig::default()));