mirror of
https://github.com/hinto-janai/cuprate.git
synced 2025-01-22 10:34:37 +00:00
4b93dbec4c
Some checks failed
Audit / audit (push) Has been cancelled
Deny / audit (push) Has been cancelled
CI / fmt (push) Has been cancelled
CI / typo (push) Has been cancelled
CI / ci (macos-latest, stable, bash) (push) Has been cancelled
CI / ci (ubuntu-latest, stable, bash) (push) Has been cancelled
CI / ci (windows-latest, stable-x86_64-pc-windows-gnu, msys2 {0}) (push) Has been cancelled
* rename all directories and crates * fix all `use` * fix doc link * `dandelion/` -> `dandelion-tower/` * fix epee-encoding test * fix `json-rpc` * fix pruning * crate import fixes * fix leftover merge conflicts * fix `epee-encoding`
43 lines
1.8 KiB
Rust
43 lines
1.8 KiB
Rust
//! Constants used around monero-p2p
|
|
|
|
use std::time::Duration;
|
|
|
|
/// The request timeout - the time we give a peer to respond to a request.
|
|
pub(crate) const REQUEST_TIMEOUT: Duration = Duration::from_secs(60);
|
|
|
|
/// The timeout used when sending messages to a peer.
|
|
///
|
|
/// TODO: Make this configurable?
|
|
/// TODO: Is this a good default.
|
|
pub(crate) const SENDING_TIMEOUT: Duration = Duration::from_secs(20);
|
|
|
|
/// The interval between timed syncs.
|
|
///
|
|
/// TODO: Make this configurable?
|
|
/// TODO: Is this a good default.
|
|
pub(crate) const TIMEOUT_INTERVAL: Duration = Duration::from_secs(61);
|
|
|
|
/// This is a Cuprate specific constant.
|
|
///
|
|
/// When completing a handshake monerod might send protocol messages before the handshake is actually
|
|
/// complete, this is a problem for Cuprate as we must complete the handshake before responding to any
|
|
/// protocol requests. So when we receive a protocol message during a handshake we keep them around to handle
|
|
/// after the handshake.
|
|
///
|
|
/// Because we use the [bytes crate](https://crates.io/crates/bytes) in monero-wire for zero-copy parsing
|
|
/// it is not safe to keep too many of these messages around for long.
|
|
pub(crate) const MAX_EAGER_PROTOCOL_MESSAGES: usize = 1;
|
|
|
|
/// A timeout put on pings during handshakes.
|
|
///
|
|
/// When we receive an inbound connection we open an outbound connection to the node and send a ping message
|
|
/// to see if we can reach the node, so we can add it to our address book.
|
|
///
|
|
/// This timeout must be significantly shorter than [`HANDSHAKE_TIMEOUT`] so we don't drop inbound connections that
|
|
/// don't have ports open.
|
|
pub(crate) const PING_TIMEOUT: Duration = Duration::from_secs(10);
|
|
|
|
/// A timeout for a handshake - the handshake must complete before this.
|
|
pub(crate) const HANDSHAKE_TIMEOUT: Duration = Duration::from_secs(60);
|
|
|
|
pub(crate) const MAX_PEERS_IN_PEER_LIST_MESSAGE: usize = 250;
|