Improve "info hash" handling

Define "torrent ID" concept, which is either a SHA1 hash for torrents of version 1,
or a SHA256 hash (truncated to SHA1 hash length) for torrents of version 2.
Add support for native libtorrent2 info hashes.
This commit is contained in:
Vladimir Golovnev (Glassez)
2021-03-05 12:43:58 +03:00
parent 4da4fb0676
commit 561b597031
34 changed files with 463 additions and 320 deletions

View File

@@ -31,6 +31,8 @@
#include <QHash>
#include "infohash.h"
namespace BitTorrent
{
uint qHash(const TorrentState key, const uint seed)
@@ -49,6 +51,11 @@ namespace BitTorrent
const qreal Torrent::MAX_RATIO = 9999;
const int Torrent::MAX_SEEDING_TIME = 525600;
TorrentID Torrent::id() const
{
return infoHash().toTorrentID();
}
bool Torrent::isResumed() const
{
return !isPaused();