Created
January 8, 2018 10:33
-
-
Save tarassh/b19835f1e570349dc13b7e9c69b991b6 to your computer and use it in GitHub Desktop.
exonum configurations for validator and auditor node.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub fn node_config() -> (NodeConfig, NodeConfig) { | |
let (validator_consensus_public_key, validator_consensus_secret_key) = exonum::crypto::gen_keypair(); | |
let (validator_service_public_key, validator_service_secret_key) = exonum::crypto::gen_keypair(); | |
let (auditor_consensus_public_key, auditor_consensus_secret_key) = exonum::crypto::gen_keypair(); | |
let (auditor_service_public_key, auditor_service_secret_key) = exonum::crypto::gen_keypair(); | |
let validator_keys = ValidatorKeys { | |
consensus_key: validator_consensus_public_key, | |
service_key: validator_service_public_key, | |
}; | |
let genesis = GenesisConfig::new(vec![validator_keys].into_iter()); | |
let api_address = "0.0.0.0:8000".parse().unwrap(); | |
let api_cfg = NodeApiConfig { | |
public_api_address: Some(api_address), | |
..Default::default() | |
}; | |
let validator_peer_address = "0.0.0.0:2000".parse().unwrap(); | |
let auditor_peer_address = "0.0.0.0:2002".parse().unwrap(); | |
let validator_config = NodeConfig { | |
listen_address: validator_peer_address, | |
peers: vec![auditor_peer_address], | |
service_public_key: validator_service_public_key, | |
service_secret_key: validator_service_secret_key, | |
consensus_public_key: validator_consensus_public_key, | |
consensus_secret_key: validator_consensus_secret_key, | |
genesis: genesis.clone(), | |
external_address: None, | |
network: Default::default(), | |
whitelist: Default::default(), | |
api: api_cfg.clone(), | |
mempool: Default::default(), | |
services_configs: Default::default(), | |
}; | |
let api_address = "0.0.0.0:8002".parse().unwrap(); | |
let api_cfg = NodeApiConfig { | |
public_api_address: Some(api_address), | |
..Default::default() | |
}; | |
let auditor_config = NodeConfig { | |
listen_address: auditor_peer_address, | |
peers: vec![validator_peer_address], | |
service_public_key: auditor_service_public_key, | |
service_secret_key: auditor_service_secret_key, | |
consensus_public_key: auditor_consensus_public_key, | |
consensus_secret_key: auditor_consensus_secret_key, | |
genesis: genesis.clone(), | |
external_address: None, | |
network: Default::default(), | |
whitelist: Default::default(), | |
api: api_cfg.clone(), | |
mempool: Default::default(), | |
services_configs: Default::default(), | |
}; | |
(validator_config, auditor_config) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment