/* */ #ifndef _D_DEFAULT_PEER_STORAGE_H_ #define _D_DEFAULT_PEER_STORAGE_H_ #include "PeerStorage.h" namespace aria2 { #define MAX_PEER_LIST_SIZE 60 #define MAX_PEER_ERROR 5 class BtContext; class Option; class Logger; class BtRuntime; class DefaultPeerStorage : public PeerStorage { private: SharedHandle btContext; const Option* option; std::deque > peers; int32_t maxPeerListSize; Logger* logger; SharedHandle btRuntime; int64_t removedPeerSessionDownloadLength; int64_t removedPeerSessionUploadLength; bool isPeerAlreadyAdded(const SharedHandle& peer); public: DefaultPeerStorage(const SharedHandle& btContext, const Option* option); virtual ~DefaultPeerStorage(); void setBtRuntime(const SharedHandle& btRuntime) { this->btRuntime = btRuntime; } SharedHandle getBtRuntime() const { return btRuntime; } virtual bool addPeer(const SharedHandle& peer); int32_t countPeer() const; virtual SharedHandle getUnusedPeer(); SharedHandle getPeer(const std::string& ipaddr, int32_t port) const; virtual void addPeer(const std::deque >& peers); virtual const std::deque >& getPeers(); virtual bool isPeerAvailable(); virtual std::deque > getActivePeers(); virtual TransferStat calculateStat(); virtual void returnPeer(const SharedHandle& peer); void setMaxPeerListSize(int32_t size) { this->maxPeerListSize = size; } int32_t getMaxPeerListSize() const { return maxPeerListSize; } void deleteUnusedPeer(int32_t delSize); void onErasingPeer(const SharedHandle& peer); }; } // namespace aria2 #endif // _D_DEFAULT_PEER_STORAGE_H_