settings.rs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. use std::{net::SocketAddr, sync::Arc};
  2. use serde::Deserialize;
  3. use structopt::StructOpt;
  4. /// Atomic pointer to network settings.
  5. pub type SettingsPtr = Arc<Settings>;
  6. /// Defines the network settings.
  7. #[derive(Clone, Debug, Deserialize, StructOpt)]
  8. #[structopt()]
  9. pub struct Settings {
  10. #[structopt(short, long)]
  11. pub inbound: Option<SocketAddr>,
  12. #[structopt(long, default_value = "0")]
  13. pub outbound_connections: u32,
  14. #[structopt(long, default_value = "0")]
  15. pub manual_attempt_limit: u32,
  16. #[structopt(long, default_value = "8")]
  17. pub seed_query_timeout_seconds: u32,
  18. #[structopt(long, default_value = "10")]
  19. pub connect_timeout_seconds: u32,
  20. #[structopt(long, default_value = "4")]
  21. pub channel_handshake_seconds: u32,
  22. #[structopt(long, default_value = "10")]
  23. pub channel_heartbeat_seconds: u32,
  24. #[structopt(short, long)]
  25. pub external_addr: Option<SocketAddr>,
  26. #[structopt(short, long)]
  27. pub peers: Vec<SocketAddr>,
  28. #[structopt(short, long)]
  29. pub seeds: Vec<SocketAddr>,
  30. }
  31. impl Default for Settings {
  32. fn default() -> Self {
  33. Self {
  34. inbound: None,
  35. outbound_connections: 0,
  36. manual_attempt_limit: 0,
  37. seed_query_timeout_seconds: 8,
  38. connect_timeout_seconds: 10,
  39. channel_handshake_seconds: 4,
  40. channel_heartbeat_seconds: 10,
  41. external_addr: None,
  42. peers: Vec::new(),
  43. seeds: Vec::new(),
  44. }
  45. }
  46. }