Allow to fetch data asynchronously

This commit is contained in:
Vladimir Golovnev (Glassez)
2022-11-14 20:45:08 +03:00
parent c3936cd4b6
commit 991c30943a
9 changed files with 410 additions and 125 deletions

View File

@@ -1,6 +1,6 @@
/*
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2015 Vladimir Golovnev <glassez@yandex.ru>
* Copyright (C) 2015-2022 Vladimir Golovnev <glassez@yandex.ru>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -31,16 +31,15 @@
#include <QBitArray>
#include "base/bittorrent/ltqbitarray.h"
#include "base/bittorrent/torrent.h"
#include "base/net/geoipmanager.h"
#include "base/unicodestrings.h"
#include "peeraddress.h"
using namespace BitTorrent;
PeerInfo::PeerInfo(const Torrent *torrent, const lt::peer_info &nativeInfo)
PeerInfo::PeerInfo(const lt::peer_info &nativeInfo, const QBitArray &allPieces)
: m_nativeInfo(nativeInfo)
, m_relevance(calcRelevance(torrent))
, m_relevance(calcRelevance(allPieces))
{
determineFlags();
}
@@ -246,9 +245,8 @@ QString PeerInfo::connectionType() const
: u"Web"_qs;
}
qreal PeerInfo::calcRelevance(const Torrent *torrent) const
qreal PeerInfo::calcRelevance(const QBitArray &allPieces) const
{
const QBitArray allPieces = torrent->pieces();
const int localMissing = allPieces.count(false);
if (localMissing <= 0)
return 0;