File indexing completed on 2025-01-05 04:37:24
0001 /* 0002 SPDX-FileCopyrightText: 2005 Joris Guisson <joris.guisson@gmail.com> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 #ifndef BTADVANCEDCHOKEALGORITHM_H 0007 #define BTADVANCEDCHOKEALGORITHM_H 0008 0009 #include "choker.h" 0010 #include <peer/peer.h> 0011 0012 namespace bt 0013 { 0014 struct TorrentStats; 0015 0016 /** 0017 @author Joris Guisson <joris.guisson@gmail.com> 0018 */ 0019 class AdvancedChokeAlgorithm : public ChokeAlgorithm 0020 { 0021 public: 0022 AdvancedChokeAlgorithm(); 0023 ~AdvancedChokeAlgorithm() override; 0024 0025 void doChokingLeechingState(PeerManager &pman, ChunkManager &cman, const TorrentStats &stats) override; 0026 void doChokingSeedingState(PeerManager &pman, ChunkManager &cman, const TorrentStats &stats) override; 0027 0028 private: 0029 bool calcACAScore(Peer::Ptr p, ChunkManager &cman, const TorrentStats &stats); 0030 Peer::Ptr updateOptimisticPeer(PeerManager &pman, const QList<Peer::Ptr> &ppl); 0031 void doUnchoking(const QList<Peer::Ptr> &ppl, Peer::Ptr poup); 0032 0033 private: 0034 TimeStamp last_opt_sel_time; // last time we updated the optimistic unchoked peer 0035 }; 0036 0037 } 0038 0039 #endif