diff --git a/include/opendht/dht.h b/include/opendht/dht.h index 5e420f84464ca69d3b04419ad3deea0fc5fb7621..91cf80306554f081215441f4dbec2a4d1a8dbb76 100644 --- a/include/opendht/dht.h +++ b/include/opendht/dht.h @@ -79,16 +79,16 @@ public: /** * Get the current status of the node for the given family. */ - NodeStatus getStatus(sa_family_t af) const; + NodeStatus getStatus(sa_family_t af) const override; - NodeStatus getStatus() const { + NodeStatus getStatus() const override { return std::max(getStatus(AF_INET), getStatus(AF_INET6)); } /** * Performs final operations before quitting. */ - void shutdown(ShutdownCallback cb); + void shutdown(ShutdownCallback cb) override; /** * Returns true if the node is running (have access to an open socket). @@ -96,12 +96,12 @@ public: * af: address family. If non-zero, will return true if the node * is running for the provided family. */ - bool isRunning(sa_family_t af = 0) const; + bool isRunning(sa_family_t af = 0) const override; - virtual void registerType(const ValueType& type) { + virtual void registerType(const ValueType& type) override { types.registerType(type); } - const ValueType& getType(ValueType::Id type_id) const { + const ValueType& getType(ValueType::Id type_id) const override { return types.getType(type_id); } @@ -110,18 +110,18 @@ public: * The node is not pinged, so this should be * used to bootstrap efficiently from previously known nodes. */ - void insertNode(const InfoHash& id, const SockAddr&); - void insertNode(const InfoHash& id, const sockaddr* sa, socklen_t salen) { + void insertNode(const InfoHash& id, const SockAddr&) override; + void insertNode(const InfoHash& id, const sockaddr* sa, socklen_t salen) override { insertNode(id, SockAddr(sa, salen)); } - void insertNode(const NodeExport& n) { + void insertNode(const NodeExport& n) override { insertNode(n.id, SockAddr(n.ss, n.sslen)); } - void pingNode(const sockaddr*, socklen_t, DoneCallbackSimple&& cb={}); + void pingNode(const sockaddr*, socklen_t, DoneCallbackSimple&& cb={}) override; - time_point periodic(const uint8_t *buf, size_t buflen, const SockAddr&); - time_point periodic(const uint8_t *buf, size_t buflen, const sockaddr* from, socklen_t fromlen) { + time_point periodic(const uint8_t *buf, size_t buflen, const SockAddr&) override; + time_point periodic(const uint8_t *buf, size_t buflen, const sockaddr* from, socklen_t fromlen) override { return periodic(buf, buflen, SockAddr(from, fromlen)); } @@ -135,14 +135,14 @@ public: cb and donecb won't be called again afterward. * @param f a filter function used to prefilter values. */ - virtual void get(const InfoHash& key, GetCallback cb, DoneCallback donecb={}, Value::Filter&& f={}, Where&& w = {}); - virtual void get(const InfoHash& key, GetCallback cb, DoneCallbackSimple donecb={}, Value::Filter&& f={}, Where&& w = {}) { + virtual void get(const InfoHash& key, GetCallback cb, DoneCallback donecb={}, Value::Filter&& f={}, Where&& w = {}) override; + virtual void get(const InfoHash& key, GetCallback cb, DoneCallbackSimple donecb={}, Value::Filter&& f={}, Where&& w = {}) override { get(key, cb, bindDoneCb(donecb), std::forward<Value::Filter>(f), std::forward<Where>(w)); } - virtual void get(const InfoHash& key, GetCallbackSimple cb, DoneCallback donecb={}, Value::Filter&& f={}, Where&& w = {}) { + virtual void get(const InfoHash& key, GetCallbackSimple cb, DoneCallback donecb={}, Value::Filter&& f={}, Where&& w = {}) override { get(key, bindGetCb(cb), donecb, std::forward<Value::Filter>(f), std::forward<Where>(w)); } - virtual void get(const InfoHash& key, GetCallbackSimple cb, DoneCallbackSimple donecb, Value::Filter&& f={}, Where&& w = {}) { + virtual void get(const InfoHash& key, GetCallbackSimple cb, DoneCallbackSimple donecb, Value::Filter&& f={}, Where&& w = {}) override { get(key, bindGetCb(cb), bindDoneCb(donecb), std::forward<Value::Filter>(f), std::forward<Where>(w)); } /** @@ -155,20 +155,20 @@ public: * @param q a query used to filter values on the remotes before they send a * response. */ - virtual void query(const InfoHash& key, QueryCallback cb, DoneCallback done_cb = {}, Query&& q = {}); - virtual void query(const InfoHash& key, QueryCallback cb, DoneCallbackSimple done_cb = {}, Query&& q = {}) { + virtual void query(const InfoHash& key, QueryCallback cb, DoneCallback done_cb = {}, Query&& q = {}) override; + virtual void query(const InfoHash& key, QueryCallback cb, DoneCallbackSimple done_cb = {}, Query&& q = {}) override { query(key, cb, bindDoneCb(done_cb), std::forward<Query>(q)); } /** * Get locally stored data for the given hash. */ - std::vector<Sp<Value>> getLocal(const InfoHash& key, const Value::Filter& f = {}) const; + std::vector<Sp<Value>> getLocal(const InfoHash& key, const Value::Filter& f = {}) const override; /** * Get locally stored data for the given key and value id. */ - Sp<Value> getLocalById(const InfoHash& key, Value::Id vid) const; + Sp<Value> getLocalById(const InfoHash& key, Value::Id vid) const override; /** * Announce a value on all available protocols (IPv4, IPv6). @@ -180,12 +180,12 @@ public: Sp<Value>, DoneCallback cb=nullptr, time_point created=time_point::max(), - bool permanent = false); + bool permanent = false) override; void put(const InfoHash& key, const Sp<Value>& v, DoneCallbackSimple cb, time_point created=time_point::max(), - bool permanent = false) + bool permanent = false) override { put(key, v, bindDoneCb(cb), created, permanent); } @@ -194,7 +194,7 @@ public: Value&& v, DoneCallback cb=nullptr, time_point created=time_point::max(), - bool permanent = false) + bool permanent = false) override { put(key, std::make_shared<Value>(std::move(v)), cb, created, permanent); } @@ -202,7 +202,7 @@ public: Value&& v, DoneCallbackSimple cb, time_point created=time_point::max(), - bool permanent = false) + bool permanent = false) override { put(key, std::forward<Value>(v), bindDoneCb(cb), created, permanent); } @@ -210,18 +210,18 @@ public: /** * Get data currently being put at the given hash. */ - std::vector<Sp<Value>> getPut(const InfoHash&) const; + std::vector<Sp<Value>> getPut(const InfoHash&) const override; /** * Get data currently being put at the given hash with the given id. */ - Sp<Value> getPut(const InfoHash&, const Value::Id&) const; + Sp<Value> getPut(const InfoHash&, const Value::Id&) const override; /** * Stop any put/announce operation at the given location, * for the value with the given id. */ - bool cancelPut(const InfoHash&, const Value::Id&); + bool cancelPut(const InfoHash&, const Value::Id&) override; /** * Listen on the network for any changes involving a specified hash. @@ -230,28 +230,28 @@ public: * * @return a token to cancel the listener later. */ - virtual size_t listen(const InfoHash&, ValueCallback, Value::Filter={}, Where={}); + size_t listen(const InfoHash&, ValueCallback, Value::Filter={}, Where={}) override; - virtual size_t listen(const InfoHash& key, GetCallback cb, Value::Filter f={}, Where w={}) { + size_t listen(const InfoHash& key, GetCallback cb, Value::Filter f={}, Where w={}) override { return listen(key, [cb](const std::vector<Sp<Value>>& vals, bool expired){ if (not expired) return cb(vals); return true; }, std::forward<Value::Filter>(f), std::forward<Where>(w)); } - virtual size_t listen(const InfoHash& key, GetCallbackSimple cb, Value::Filter f={}, Where w={}) { + size_t listen(const InfoHash& key, GetCallbackSimple cb, Value::Filter f={}, Where w={}) override { return listen(key, bindGetCb(cb), std::forward<Value::Filter>(f), std::forward<Where>(w)); } - virtual bool cancelListen(const InfoHash&, size_t token); + bool cancelListen(const InfoHash&, size_t token) override; /** * Inform the DHT of lower-layer connectivity changes. * This will cause the DHT to assume a public IP address change. * The DHT will recontact neighbor nodes, re-register for listen ops etc. */ - void connectivityChanged(sa_family_t); - void connectivityChanged() { + void connectivityChanged(sa_family_t) override; + void connectivityChanged() override { reported_addr.clear(); connectivityChanged(AF_INET); connectivityChanged(AF_INET6); @@ -261,18 +261,18 @@ public: * Get the list of good nodes for local storage saving purposes * The list is ordered to minimize the back-to-work delay. */ - std::vector<NodeExport> exportNodes() const; + std::vector<NodeExport> exportNodes() const override; - std::vector<ValuesExport> exportValues() const; - void importValues(const std::vector<ValuesExport>&); + std::vector<ValuesExport> exportValues() const override; + void importValues(const std::vector<ValuesExport>&) override; void saveState(const std::string& path) const; void loadState(const std::string& path); - NodeStats getNodesStats(sa_family_t af) const; + NodeStats getNodesStats(sa_family_t af) const override; - std::string getStorageLog() const; - std::string getStorageLog(const InfoHash&) const; + std::string getStorageLog() const override; + std::string getStorageLog(const InfoHash&) const override; std::string getRoutingTablesLog(sa_family_t) const; std::string getSearchesLog(sa_family_t) const; @@ -298,9 +298,9 @@ public: return {total_store_size, total_values}; } - std::vector<SockAddr> getPublicAddress(sa_family_t family = 0); + std::vector<SockAddr> getPublicAddress(sa_family_t family = 0) override; - void pushNotificationReceived(const std::map<std::string, std::string>&) {} + void pushNotificationReceived(const std::map<std::string, std::string>&) override {} void resubscribe(unsigned) {} private: