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