libktorrent  2.2.0
advancedchokealgorithm.h
1 /***************************************************************************
2  * Copyright (C) 2005 by Joris Guisson *
3  * joris.guisson@gmail.com *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19  ***************************************************************************/
20 #ifndef BTADVANCEDCHOKEALGORITHM_H
21 #define BTADVANCEDCHOKEALGORITHM_H
22 
23 #include <peer/peer.h>
24 #include "choker.h"
25 
26 
27 namespace bt
28 {
29  struct TorrentStats;
30 
31 
36  {
37  public:
39  ~AdvancedChokeAlgorithm() override;
40 
41  void doChokingLeechingState(PeerManager & pman, ChunkManager & cman, const TorrentStats & stats) override;
42  void doChokingSeedingState(PeerManager & pman, ChunkManager & cman, const TorrentStats & stats) override;
43 
44  private:
45  bool calcACAScore(Peer::Ptr p, ChunkManager & cman, const TorrentStats & stats);
46  Peer::Ptr updateOptimisticPeer(PeerManager & pman, const QList<Peer::Ptr> & ppl);
47  void doUnchoking(QList<Peer::Ptr> & ppl, Peer::Ptr poup);
48 
49  private:
50  TimeStamp last_opt_sel_time; // last time we updated the optimistic unchoked peer
51  };
52 
53 }
54 
55 #endif
bt::AdvancedChokeAlgorithm
Definition: advancedchokealgorithm.h:36
bt::ChunkManager
Definition: chunkmanager.h:61
bt::PeerManager
Manages all the Peers.
Definition: peermanager.h:67
bt::TorrentStats
Definition: torrentstats.h:55
bt::AdvancedChokeAlgorithm::doChokingLeechingState
void doChokingLeechingState(PeerManager &pman, ChunkManager &cman, const TorrentStats &stats) override
bt::ChokeAlgorithm
Definition: choker.h:41
bt::AdvancedChokeAlgorithm::doChokingSeedingState
void doChokingSeedingState(PeerManager &pman, ChunkManager &cman, const TorrentStats &stats) override