You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
//! `completed` | 20 | The number of peers that have ever completed downloading the torrent associated to this entry. See [`Entry`](torrust_tracker_torrent_repository::entry::Entry) for more information.
//! The [`torrent`](crate::torrent) module contains all the data structures stored by the `Tracker` except for peers.
58
+
//!
59
+
//! We can represent the data stored in memory internally by the `Tracker` with this JSON object:
60
+
//!
61
+
//! ```json
62
+
//! {
63
+
//! "c1277613db1d28709b034a017ab2cae4be07ae10": {
64
+
//! "completed": 0,
65
+
//! "peers": {
66
+
//! "-qB00000000000000001": {
67
+
//! "peer_id": "-qB00000000000000001",
68
+
//! "peer_addr": "2.137.87.41:1754",
69
+
//! "updated": 1672419840,
70
+
//! "uploaded": 120,
71
+
//! "downloaded": 60,
72
+
//! "left": 60,
73
+
//! "event": "started"
74
+
//! },
75
+
//! "-qB00000000000000002": {
76
+
//! "peer_id": "-qB00000000000000002",
77
+
//! "peer_addr": "23.17.287.141:2345",
78
+
//! "updated": 1679415984,
79
+
//! "uploaded": 80,
80
+
//! "downloaded": 20,
81
+
//! "left": 40,
82
+
//! "event": "started"
83
+
//! }
84
+
//! }
85
+
//! }
86
+
//! }
87
+
//! ```
88
+
//!
89
+
//! The `Tracker` maintains an indexed-by-info-hash list of torrents. For each torrent, it stores a torrent `Entry`.
90
+
//! The torrent entry has two attributes:
91
+
//!
92
+
//! - `completed`: which is hte number of peers that have completed downloading the torrent file/s. As they have completed downloading,
93
+
//! they have a full version of the torrent data, and they can provide the full data to other peers. That's why they are also known as "seeders".
94
+
//! - `peers`: an indexed and orderer list of peer for the torrent. Each peer contains the data received from the peer in the `announce` request.
95
+
//!
96
+
//! The [`crate::torrent`] module not only contains the original data obtained from peer via `announce` requests, it also contains
97
+
//! aggregate data that can be derived from the original data. For example:
98
+
//!
99
+
//! ```rust,no_run
100
+
//! pub struct SwarmMetadata {
101
+
//! pub complete: u32, // The number of active peers that have completed downloading (seeders)
102
+
//! pub downloaded: u32, // The number of peers that have ever completed downloading
103
+
//! pub incomplete: u32, // The number of active peers that have not completed downloading (leechers)
104
+
//! }
105
+
//!
106
+
//! ```
107
+
//!
108
+
//! > **NOTICE**: that `complete` or `completed` peers are the peers that have completed downloading, but only the active ones are considered "seeders".
109
+
//!
110
+
//! `SwarmMetadata` struct follows name conventions for `scrape` responses. See [BEP 48](https://www.bittorrent.org/beps/bep_0048.html), while `SwarmMetadata`
111
+
//! is used for the rest of cases.
112
+
//!
113
+
//! Refer to [`crate::torrent`] module for more details about these data structures.
114
+
//!
115
+
//! ## Peers
116
+
//!
117
+
//! A `Peer` is the struct used by the `Tracker` to keep peers data:
118
+
//!
119
+
//! ```rust,no_run
120
+
//! use std::net::SocketAddr;
121
+
//! use aquatic_udp_protocol::PeerId;
122
+
//! use torrust_tracker_primitives::DurationSinceUnixEpoch;
//! The `Tracker` keeps an in-memory ordered data structure with all the torrents and a list of peers for each torrent, together with some swarm metrics.
143
+
//!
144
+
//! We can represent the data stored in memory with this JSON object:
145
+
//!
146
+
//! ```json
147
+
//! {
148
+
//! "c1277613db1d28709b034a017ab2cae4be07ae10": {
149
+
//! "completed": 0,
150
+
//! "peers": {
151
+
//! "-qB00000000000000001": {
152
+
//! "peer_id": "-qB00000000000000001",
153
+
//! "peer_addr": "2.137.87.41:1754",
154
+
//! "updated": 1672419840,
155
+
//! "uploaded": 120,
156
+
//! "downloaded": 60,
157
+
//! "left": 60,
158
+
//! "event": "started"
159
+
//! },
160
+
//! "-qB00000000000000002": {
161
+
//! "peer_id": "-qB00000000000000002",
162
+
//! "peer_addr": "23.17.287.141:2345",
163
+
//! "updated": 1679415984,
164
+
//! "uploaded": 80,
165
+
//! "downloaded": 20,
166
+
//! "left": 40,
167
+
//! "event": "started"
168
+
//! }
169
+
//! }
170
+
//! }
171
+
//! }
172
+
//! ```
173
+
//!
174
+
//! That JSON object does not exist, it's only a representation of the `Tracker` torrents data.
175
+
//!
176
+
//! `c1277613db1d28709b034a017ab2cae4be07ae10` is the torrent infohash and `completed` contains the number of peers
177
+
//! that have a full version of the torrent data, also known as seeders.
178
+
//!
179
+
//! Refer to [`peer`](torrust_tracker_primitives::peer) for more information about peers.
180
+
//!
181
+
//! # Persistence
182
+
//!
183
+
//! Right now the `Tracker` is responsible for storing and load data into and
184
+
//! from the database, when persistence is enabled.
185
+
//!
186
+
//! There are three types of persistent object:
187
+
//!
188
+
//! - Authentication keys (only expiring keys)
189
+
//! - Torrent whitelist
190
+
//! - Torrent metrics
191
+
//!
192
+
//! Refer to [`crate::databases`] module for more information about persistence.
0 commit comments