/* */ #ifndef D_BT_SEEDER_STATE_CHOKE_H #define D_BT_SEEDER_STATE_CHOKE_H #include "common.h" #include #include "SharedHandle.h" #include "TimerA2.h" namespace aria2 { class Peer; class BtSeederStateChoke { private: int round_; Timer lastRound_; class PeerEntry { private: SharedHandle peer_; size_t outstandingUpload_; Timer lastAmUnchoking_; bool recentUnchoking_; unsigned int uploadSpeed_; const static time_t TIME_FRAME = 20; public: PeerEntry(const SharedHandle& peer); PeerEntry(const PeerEntry& c); ~PeerEntry(); PeerEntry& operator=(const PeerEntry& c); bool operator<(const PeerEntry& rhs) const; const SharedHandle& getPeer() const { return peer_; } unsigned int getUploadSpeed() const { return uploadSpeed_; } void disableOptUnchoking(); }; void unchoke(std::vector& peers); class GenPeerEntry { public: PeerEntry operator()(const SharedHandle& peer) const { return PeerEntry(peer); } }; class NotInterestedPeer { public: bool operator()(const PeerEntry& peerEntry) const; }; public: BtSeederStateChoke(); ~BtSeederStateChoke(); void executeChoke(const std::vector >& peerSet); const Timer& getLastRound() const { return lastRound_; } }; } // namespace aria2 #endif // D_BT_SEEDER_STATE_CHOKE_H