Skip to content

Commit 4323d96

Browse files
committed
Add missing documentation
1 parent a11235d commit 4323d96

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

src/lib.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Bitcoin Peer-to-Peer connections.
2+
#![warn(missing_docs)]
13
use std::{
24
collections::HashMap,
35
sync::{
@@ -143,8 +145,15 @@ impl ConnectionMetrics {
143145
/// The rate at which a peer sends a particular message
144146
#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
145147
pub enum MessageRate {
148+
/// No message of this type has been received.
146149
NoneReceived,
147-
Ongoing { count: f64, start: Instant },
150+
/// The total count of messages along with the first message of this type.
151+
Ongoing {
152+
/// Total count of messages
153+
count: f64,
154+
/// The time of the first message
155+
start: Instant
156+
},
148157
}
149158

150159
impl MessageRate {
@@ -257,7 +266,9 @@ enum OutboundPing {
257266
LastReceived { then: Instant },
258267
}
259268

269+
/// DNS seed provider
260270
pub trait SeedsExt {
271+
/// List DNS seeds
261272
fn seeds(&self) -> Vec<&str>;
262273
}
263274

src/net.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,11 @@ use crate::{
2424
ConnectionMetrics, OutboundPing, Preferences, TimedMessage, TimedMessages,
2525
};
2626

27+
/// Maximum amount of time the peer has to seed a message after idling.
2728
pub const READ_TIMEOUT: Duration = Duration::from_secs(60);
29+
/// The interval to send a new ping message.
2830
pub const PING_INTERVAL: Duration = Duration::from_secs(30);
31+
/// The initial TCP handshake timeout.
2932
pub const TCP_TIMEOUT: Duration = Duration::from_secs(2);
3033

3134
/// Open or begin a connection to an inbound or outbound peer.
@@ -151,6 +154,7 @@ impl ConnectionExt for ConnectionConfig {
151154
}
152155
}
153156

157+
/// Configurations for ending a connection due to inactivity.
154158
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
155159
pub struct TimeoutParams {
156160
read: Option<Duration>,
@@ -160,22 +164,27 @@ pub struct TimeoutParams {
160164
}
161165

162166
impl TimeoutParams {
167+
/// Construct new timeout parameters
163168
pub fn new() -> Self {
164169
Self::default()
165170
}
166171

172+
/// Set the time a peer has until they have must sent a message.
167173
pub fn read_timeout(&mut self, timeout: Duration) {
168174
self.read = Some(timeout)
169175
}
170-
176+
177+
/// Maximum amount of time it should take to write a message.
171178
pub fn write_timeout(&mut self, timeout: Duration) {
172179
self.write = Some(timeout)
173180
}
174181

182+
/// The initial TCP handshake timeout.
175183
pub fn tcp_handshake_timeout(&mut self, timeout: Duration) {
176184
self.tcp = timeout;
177185
}
178186

187+
/// How often is this peer pinged for activity
179188
pub fn ping_interval(&mut self, every: Duration) {
180189
self.ping_interval = every
181190
}

0 commit comments

Comments
 (0)