/* */ #ifndef _D_DEFAULT_PEER_STORAGE_H_ #define _D_DEFAULT_PEER_STORAGE_H_ #include "PeerStorage.h" #include #include "TimerA2.h" namespace aria2 { class Logger; class BtRuntime; class BtSeederStateChoke; class BtLeecherStateChoke; class PieceStorage; class DefaultPeerStorage : public PeerStorage { private: SharedHandle _btRuntime; SharedHandle _pieceStorage; std::deque > _peers; Logger* _logger; uint64_t _removedPeerSessionDownloadLength; uint64_t _removedPeerSessionUploadLength; BtSeederStateChoke* _seederStateChoke; BtLeecherStateChoke* _leecherStateChoke; std::map _peerTransferStatMap; Timer _lastTransferStatMapUpdated; TransferStat _cachedTransferStat; bool isPeerAlreadyAdded(const SharedHandle& peer); public: DefaultPeerStorage(); 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::vector >& peers); virtual const std::deque >& getPeers(); virtual bool isPeerAvailable(); virtual void getActivePeers(std::vector >& 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_