Guest User

Untitled

a guest
Jan 16th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.41 KB | None | 0 0
  1. pub fn node_config() -> (NodeConfig, NodeConfig) {
  2. let (validator_consensus_public_key, validator_consensus_secret_key) = exonum::crypto::gen_keypair();
  3. let (validator_service_public_key, validator_service_secret_key) = exonum::crypto::gen_keypair();
  4. let (auditor_consensus_public_key, auditor_consensus_secret_key) = exonum::crypto::gen_keypair();
  5. let (auditor_service_public_key, auditor_service_secret_key) = exonum::crypto::gen_keypair();
  6.  
  7. let validator_keys = ValidatorKeys {
  8. consensus_key: validator_consensus_public_key,
  9. service_key: validator_service_public_key,
  10. };
  11. let genesis = GenesisConfig::new(vec![validator_keys].into_iter());
  12.  
  13. let api_address = "0.0.0.0:8000".parse().unwrap();
  14. let api_cfg = NodeApiConfig {
  15. public_api_address: Some(api_address),
  16. ..Default::default()
  17. };
  18.  
  19. let validator_peer_address = "0.0.0.0:2000".parse().unwrap();
  20. let auditor_peer_address = "0.0.0.0:2002".parse().unwrap();
  21.  
  22. let validator_config = NodeConfig {
  23. listen_address: validator_peer_address,
  24. peers: vec![auditor_peer_address],
  25. service_public_key: validator_service_public_key,
  26. service_secret_key: validator_service_secret_key,
  27. consensus_public_key: validator_consensus_public_key,
  28. consensus_secret_key: validator_consensus_secret_key,
  29. genesis: genesis.clone(),
  30. external_address: None,
  31. network: Default::default(),
  32. whitelist: Default::default(),
  33. api: api_cfg.clone(),
  34. mempool: Default::default(),
  35. services_configs: Default::default(),
  36. };
  37.  
  38. let api_address = "0.0.0.0:8002".parse().unwrap();
  39. let api_cfg = NodeApiConfig {
  40. public_api_address: Some(api_address),
  41. ..Default::default()
  42. };
  43.  
  44. let auditor_config = NodeConfig {
  45. listen_address: auditor_peer_address,
  46. peers: vec![validator_peer_address],
  47. service_public_key: auditor_service_public_key,
  48. service_secret_key: auditor_service_secret_key,
  49. consensus_public_key: auditor_consensus_public_key,
  50. consensus_secret_key: auditor_consensus_secret_key,
  51. genesis: genesis.clone(),
  52. external_address: None,
  53. network: Default::default(),
  54. whitelist: Default::default(),
  55. api: api_cfg.clone(),
  56. mempool: Default::default(),
  57. services_configs: Default::default(),
  58. };
  59.  
  60. (validator_config, auditor_config)
  61. }
Add Comment
Please, Sign In to add comment