Skip to content

Commit 9362fa5

Browse files
committed
dev: use aquatic PeerId instead of local one
1 parent 03e88d0 commit 9362fa5

File tree

26 files changed

+244
-317
lines changed

26 files changed

+244
-317
lines changed

docs/media/flamegraph_generated_without_sudo.svg

+1-1
Loading

packages/primitives/src/lib.rs

-44
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77
use std::collections::BTreeMap;
88
use std::time::Duration;
99

10-
use aquatic_udp_protocol::{AnnounceEvent, NumberOfBytes};
1110
use info_hash::InfoHash;
12-
use serde::Serialize;
1311

1412
pub mod info_hash;
1513
pub mod pagination;
@@ -20,48 +18,6 @@ pub mod torrent_metrics;
2018
/// Duration since the Unix Epoch.
2119
pub type DurationSinceUnixEpoch = Duration;
2220

23-
/// Serializes a `DurationSinceUnixEpoch` as a Unix timestamp in milliseconds.
24-
/// # Errors
25-
///
26-
/// Will return `serde::Serializer::Error` if unable to serialize the `unix_time_value`.
27-
pub fn ser_unix_time_value<S: serde::Serializer>(unix_time_value: &DurationSinceUnixEpoch, ser: S) -> Result<S::Ok, S::Error> {
28-
#[allow(clippy::cast_possible_truncation)]
29-
ser.serialize_u64(unix_time_value.as_millis() as u64)
30-
}
31-
32-
#[derive(Serialize)]
33-
pub enum AnnounceEventSer {
34-
Started,
35-
Stopped,
36-
Completed,
37-
None,
38-
}
39-
40-
/// Serializes a `Announce Event` as a enum.
41-
///
42-
/// # Errors
43-
///
44-
/// If will return an error if the internal serializer was to fail.
45-
pub fn ser_announce_event<S: serde::Serializer>(announce_event: &AnnounceEvent, ser: S) -> Result<S::Ok, S::Error> {
46-
let event_ser = match announce_event {
47-
AnnounceEvent::Started => AnnounceEventSer::Started,
48-
AnnounceEvent::Stopped => AnnounceEventSer::Stopped,
49-
AnnounceEvent::Completed => AnnounceEventSer::Completed,
50-
AnnounceEvent::None => AnnounceEventSer::None,
51-
};
52-
53-
ser.serialize_some(&event_ser)
54-
}
55-
56-
/// Serializes a `Announce Event` as a i64.
57-
///
58-
/// # Errors
59-
///
60-
/// If will return an error if the internal serializer was to fail.
61-
pub fn ser_number_of_bytes<S: serde::Serializer>(number_of_bytes: &NumberOfBytes, ser: S) -> Result<S::Ok, S::Error> {
62-
ser.serialize_i64(number_of_bytes.0.get())
63-
}
64-
6521
/// IP version used by the peer to connect to the tracker: IPv4 or IPv6
6622
#[derive(PartialEq, Eq, Debug)]
6723
pub enum IPVersion {

0 commit comments

Comments
 (0)