Go to the documentation of this file.
6 #include <shared_mutex>
9 #include <unordered_map>
33 std::optional<download::Downloaded> _data;
55 [[nodiscard]]
bool download(
const peer::Peer& peer);
57 [[nodiscard]]
bool save()
const;
66 int64_t piece_processed = 0;
75 mutable std::shared_mutex _mtx;
77 std::unordered_map<TorrentID, Torrent> _torrents;
82 std::string _download_folder;
114 void thread_main(
mt::Runner runner, WorkerState& state, int64_t index);
118 bool prepare_torrent_files(
TorrentFile& descriptor);
void remove_torrent(TorrentID tid)
Removes a torrent descriptor and all of his tasks.
Definition: furrent.cpp:367
TorrentID tid
Identifier of the owner torrent.
Definition: furrent.hpp:37
Result< TorrentID > add_torrent(const std::string &filename)
Begin download of a torrent.
Definition: furrent.cpp:305
TorrentID tid
Definition: furrent.hpp:15
TorrentGuiData get_gui_data(TorrentID tid) const
Extract torrents stats.
Definition: furrent.cpp:382
Class responsible for processing a piece.
Definition: furrent.hpp:31
PieceTaskStats process(const peer::Peer &peer)
Process piece, downloads it from a peer and saves it to file.
Definition: furrent.cpp:24
virtual ~Furrent()
Definition: furrent.cpp:102
Used to handle errors without using exceptions.
Definition: result.hpp:18
TorrentState state
Definition: furrent.hpp:16
int64_t TorrentID
Definition: types.hpp:8
Error
All possible Furrent errors.
Definition: furrent.hpp:86
Definition: furrent.hpp:62
int64_t pieces_count
Definition: furrent.hpp:20
Definition: furrent.hpp:25
Furrent()
Definition: furrent.cpp:82
TorrentFile descriptor
.torrent descriptor
Definition: furrent.hpp:41
Piece piece
Piece to process.
Definition: furrent.hpp:39
Represents a single peer as given by the tracker.
Definition: peer.hpp:19
Definition: result.hpp:51
Definition: furrent.hpp:14
std::string filename
Definition: furrent.hpp:17
Represents a parsed .torrent file.
Definition: torrent.hpp:32
TorrentState
Definition: torrent.hpp:82
bool completed
True if the operation was successfull.
Definition: furrent.hpp:27
Result< Empty > set_download_folder(const std::string &folder)
Set the download folder.
Definition: furrent.cpp:107
Definition: singleton.hpp:6
int64_t pieces_processed
Definition: furrent.hpp:19
Used to control threads execution.
Definition: group.hpp:19
PieceTask()
Constructs an empty temporary piece task.
Definition: furrent.cpp:14
Definition: torrent.hpp:75
Definition: sharing_queue.hpp:26
Common types used in all the project.
Definition: bencode_parser.cpp:7