/* */ #ifndef _D_DHT_NODE_H_ #define _D_DHT_NODE_H_ #include "common.h" #include "SharedHandle.h" #include "DHTConstants.h" #include "TimeA2.h" #include namespace aria2 { class DHTNode { private: unsigned char _id[DHT_ID_LENGTH]; std::string _ipaddr; uint16_t _port; // in milli sec unsigned int _rtt; unsigned int _condition; Time _lastContact; public: DHTNode(); /** * id must be 20 bytes length */ DHTNode(const unsigned char* id); void generateID(); const unsigned char* getID() const { return _id; } void updateRTT(unsigned int millisec) { _rtt = millisec; } std::string getIPAddress() const { return _ipaddr; } void setIPAddress(const std::string& ipaddr) { _ipaddr = ipaddr; } void setID(const unsigned char* id); uint16_t getPort() const { return _port; } void setPort(uint16_t port) { _port = port; } bool isGood() const; bool isBad() const; bool isQuestionable() const; void updateLastContact(); void markGood(); void markBad(); void timeout(); bool operator==(const DHTNode& node) const; bool operator<(const DHTNode& node) const; std::string toString() const; }; } // namespace aria2 #endif // _D_DHT_NODE_H_