Skip to content

Commit

Permalink
Merge pull request #304 from tox-rs/consts
Browse files Browse the repository at this point in the history
DHT consts improvements
  • Loading branch information
kpp authored Jan 18, 2019
2 parents a2a69bc + 7a37eb1 commit 2a6d088
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/toxcore/dht/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ type TcpOnionTx = mpsc::Sender<(InnerOnionResponse, SocketAddr)>;
/// After random requests count exceeds this number `NODES_REQ_INTERVAL` will be
/// used.
pub const MAX_BOOTSTRAP_TIMES: u32 = 5;
/// Interval in seconds of sending `NatPingRequest` packet.
pub const NAT_PING_REQ_INTERVAL: u64 = 3;
/// How often onion key should be refreshed.
pub const ONION_REFRESH_KEY_INTERVAL: u64 = 7200;
/// Interval in seconds for random `NodesRequest`.
Expand All @@ -69,6 +67,8 @@ pub const PRECOMPUTED_LRU_CACHE_SIZE: usize = KBUCKET_DEFAULT_SIZE as usize * KB
KBUCKET_DEFAULT_SIZE as usize * (2 + 10); // For friend's close_nodes of 2 fake friends + 10 friends reserved
/// Timeout in seconds for packet sending
pub const DHT_SEND_TIMEOUT: u64 = 1;
/// How often DHT main loop should be called.
const MAIN_LOOP_INTERVAL: u64 = 1;

/// Struct that contains necessary data for `BootstrapInfo` packet.
#[derive(Clone)]
Expand Down Expand Up @@ -371,7 +371,7 @@ impl Server {
/// Run DHT main loop periodically. Result future will never be completed
/// successfully.
fn run_main_loop(self) -> impl Future<Item = (), Error = Error> + Send {
let interval = Duration::from_secs(1);
let interval = Duration::from_secs(MAIN_LOOP_INTERVAL);
let wakeups = Interval::new(Instant::now(), interval);
wakeups
.map_err(|e| Error::new(ErrorKind::Other, format!("DHT server timer error: {:?}", e)))
Expand Down

0 comments on commit 2a6d088

Please sign in to comment.