Go to the documentation of this file.
28 [[nodiscard]] std::string
filename()
const;
99 std::vector<peer::Peer> _peers;
101 std::deque<std::atomic_int64_t> _peers_score;
103 int64_t _update_interval;
137 [[nodiscard]] std::vector<peer::Peer>
peers()
const;
140 [[nodiscard]] std::discrete_distribution<int64_t>
distribution()
const;
143 [[nodiscard]] std::vector<Piece>
pieces()
const;
TorrentID tid() const
Returns unique id.
Definition: torrent.cpp:171
hash::hash_t info_hash
Definition: torrent.hpp:38
std::string filename() const
Definition: torrent.cpp:16
TorrentFile()=default
Construct an empty TorrentFile instance.
std::vector< Subpiece > subpieces
Mapping piece-files.
Definition: torrent.hpp:79
int64_t file_offset
Offset from the beginning of the file.
Definition: torrent.hpp:68
int64_t index
Global download index.
Definition: torrent.hpp:77
int64_t len
Size in bytes.
Definition: torrent.hpp:70
std::array< uint8_t, 20 > hash_t
Type for a SHA1 hash.
Definition: hash.hpp:13
int64_t TorrentID
Definition: types.hpp:8
std::vector< peer::Peer > peers() const
Returns the loaded peers.
Definition: torrent.cpp:175
std::vector< hash::hash_t > piece_hashes
SHA1 hashes, one for each piece of the shared file.
Definition: torrent.hpp:40
void atomic_add_peer_score(int64_t peer_index)
Definition: torrent.cpp:155
std::string folder_name
Name of the folder containing all torrent files.
Definition: torrent.hpp:51
int64_t length
Number of bytes in the file.
Definition: torrent.hpp:23
Torrent()
Construct empty temporary torrent.
Definition: torrent.cpp:118
std::vector< File > files
Describe the structure of the file.
Definition: torrent.hpp:53
int64_t piece_length
The length, in bytes, of each piece.
Definition: torrent.hpp:42
Represents a parsed .torrent file.
Definition: torrent.hpp:32
std::atomic_int64_t pieces_processed
Definition: torrent.hpp:112
std::string filepath
Path to the file this subpiece belongs to.
Definition: torrent.hpp:66
TorrentState
Definition: torrent.hpp:82
Describes a subsection of a Piece, it is mapped to a single file.
Definition: torrent.hpp:64
Definition: bencode_value.hpp:14
Describes a file inside a torrent.
Definition: torrent.hpp:18
void announce()
Announces the client to the tracker and sets the list of peers.
Definition: torrent.cpp:133
int64_t pieces_count
Total number of pieces.
Definition: torrent.hpp:46
int64_t length
The length, in bytes, of the entire shared file.
Definition: torrent.hpp:44
const TorrentFile & descriptor() const
Returns the .torrent descriptor.
Definition: torrent.cpp:173
std::string name
The name of the shared file.
Definition: torrent.hpp:48
std::string announce_url
Definition: torrent.hpp:35
std::discrete_distribution< int64_t > distribution() const
Returns a peer distribution.
Definition: torrent.cpp:161
Completely describes a torrent in furrent.
Definition: torrent.hpp:92
std::vector< std::string > filepath
Definition: torrent.hpp:21
Definition: torrent.hpp:75
std::atomic< TorrentState > state
Definition: torrent.hpp:108
Common types used in all the project.
Definition: bencode_parser.cpp:7
std::vector< Piece > pieces() const
Generate all pieces of this torrent.
Definition: torrent.cpp:178