/* */ #ifndef _D_DEFAULT_PEER_STORAGE_H_ #define _D_DEFAULT_PEER_STORAGE_H_ #include "PeerStorage.h" #include #include "TimeA2.h" namespace aria2 { class Option; class Logger; class BtRuntime; class BtSeederStateChoke; class BtLeecherStateChoke; class PieceStorage; class DefaultPeerStorage : public PeerStorage { private: SharedHandle _btRuntime; SharedHandle _pieceStorage; const Option* option; std::deque > peers; Logger* logger; uint64_t removedPeerSessionDownloadLength; uint64_t removedPeerSessionUploadLength; BtSeederStateChoke* _seederStateChoke; BtLeecherStateChoke* _leecherStateChoke; std::map _peerTransferStatMap; Time _lastTransferStatMapUpdated; TransferStat _cachedTransferStat; bool isPeerAlreadyAdded(const SharedHandle& peer); public: DefaultPeerStorage(const Option* option); virtual ~DefaultPeerStorage(); virtual bool addPeer(const SharedHandle& peer); size_t countPeer() const; virtual SharedHandle getUnusedPeer(); SharedHandle getPeer(const std::string& ipaddr, uint16_t port) const; virtual void addPeer(const std::deque >& peers); virtual const std::deque >& getPeers(); virtual bool isPeerAvailable(); virtual void getActivePeers(std::deque >& peers); virtual TransferStat calculateStat(); virtual void updateTransferStatFor(const SharedHandle& peer); virtual TransferStat getTransferStatFor(const SharedHandle& peer); virtual void returnPeer(const SharedHandle& peer); virtual bool chokeRoundIntervalElapsed(); virtual void executeChoke(); void deleteUnusedPeer(size_t delSize); void onErasingPeer(const SharedHandle& peer); void onReturningPeer(const SharedHandle& peer); void setPieceStorage(const SharedHandle& pieceStorage); void setBtRuntime(const SharedHandle& btRuntime); }; } // namespace aria2 #endif // _D_DEFAULT_PEER_STORAGE_H_