Skip to content
Snippets Groups Projects
Commit 5ec72e21 authored by Adrien Béraud's avatar Adrien Béraud
Browse files

dht: add override

parent 683a1117
No related branches found
No related tags found
No related merge requests found
...@@ -79,16 +79,16 @@ public: ...@@ -79,16 +79,16 @@ public:
/** /**
* Get the current status of the node for the given family. * 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)); return std::max(getStatus(AF_INET), getStatus(AF_INET6));
} }
/** /**
* Performs final operations before quitting. * 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). * Returns true if the node is running (have access to an open socket).
...@@ -96,12 +96,12 @@ public: ...@@ -96,12 +96,12 @@ public:
* af: address family. If non-zero, will return true if the node * af: address family. If non-zero, will return true if the node
* is running for the provided family. * 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); 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); return types.getType(type_id);
} }
...@@ -110,18 +110,18 @@ public: ...@@ -110,18 +110,18 @@ public:
* The node is not pinged, so this should be * The node is not pinged, so this should be
* used to bootstrap efficiently from previously known nodes. * used to bootstrap efficiently from previously known nodes.
*/ */
void insertNode(const InfoHash& id, const SockAddr&); void insertNode(const InfoHash& id, const SockAddr&) override;
void insertNode(const InfoHash& id, const sockaddr* sa, socklen_t salen) { void insertNode(const InfoHash& id, const sockaddr* sa, socklen_t salen) override {
insertNode(id, SockAddr(sa, salen)); insertNode(id, SockAddr(sa, salen));
} }
void insertNode(const NodeExport& n) { void insertNode(const NodeExport& n) override {
insertNode(n.id, SockAddr(n.ss, n.sslen)); 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&) override;
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* from, socklen_t fromlen) override {
return periodic(buf, buflen, SockAddr(from, fromlen)); return periodic(buf, buflen, SockAddr(from, fromlen));
} }
...@@ -135,14 +135,14 @@ public: ...@@ -135,14 +135,14 @@ public:
cb and donecb won't be called again afterward. cb and donecb won't be called again afterward.
* @param f a filter function used to prefilter values. * @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, DoneCallback donecb={}, Value::Filter&& f={}, Where&& w = {}) override;
virtual void get(const InfoHash& key, GetCallback cb, DoneCallbackSimple donecb={}, Value::Filter&& f={}, Where&& w = {}) { 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)); 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)); 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)); get(key, bindGetCb(cb), bindDoneCb(donecb), std::forward<Value::Filter>(f), std::forward<Where>(w));
} }
/** /**
...@@ -155,20 +155,20 @@ public: ...@@ -155,20 +155,20 @@ public:
* @param q a query used to filter values on the remotes before they send a * @param q a query used to filter values on the remotes before they send a
* response. * response.
*/ */
virtual void query(const InfoHash& key, QueryCallback cb, DoneCallback 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 = {}) { virtual void query(const InfoHash& key, QueryCallback cb, DoneCallbackSimple done_cb = {}, Query&& q = {}) override {
query(key, cb, bindDoneCb(done_cb), std::forward<Query>(q)); query(key, cb, bindDoneCb(done_cb), std::forward<Query>(q));
} }
/** /**
* Get locally stored data for the given hash. * 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. * 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). * Announce a value on all available protocols (IPv4, IPv6).
...@@ -180,12 +180,12 @@ public: ...@@ -180,12 +180,12 @@ public:
Sp<Value>, Sp<Value>,
DoneCallback cb=nullptr, DoneCallback cb=nullptr,
time_point created=time_point::max(), time_point created=time_point::max(),
bool permanent = false); bool permanent = false) override;
void put(const InfoHash& key, void put(const InfoHash& key,
const Sp<Value>& v, const Sp<Value>& v,
DoneCallbackSimple cb, DoneCallbackSimple cb,
time_point created=time_point::max(), time_point created=time_point::max(),
bool permanent = false) bool permanent = false) override
{ {
put(key, v, bindDoneCb(cb), created, permanent); put(key, v, bindDoneCb(cb), created, permanent);
} }
...@@ -194,7 +194,7 @@ public: ...@@ -194,7 +194,7 @@ public:
Value&& v, Value&& v,
DoneCallback cb=nullptr, DoneCallback cb=nullptr,
time_point created=time_point::max(), 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); put(key, std::make_shared<Value>(std::move(v)), cb, created, permanent);
} }
...@@ -202,7 +202,7 @@ public: ...@@ -202,7 +202,7 @@ public:
Value&& v, Value&& v,
DoneCallbackSimple cb, DoneCallbackSimple cb,
time_point created=time_point::max(), time_point created=time_point::max(),
bool permanent = false) bool permanent = false) override
{ {
put(key, std::forward<Value>(v), bindDoneCb(cb), created, permanent); put(key, std::forward<Value>(v), bindDoneCb(cb), created, permanent);
} }
...@@ -210,18 +210,18 @@ public: ...@@ -210,18 +210,18 @@ public:
/** /**
* Get data currently being put at the given hash. * 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. * 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, * Stop any put/announce operation at the given location,
* for the value with the given id. * 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. * Listen on the network for any changes involving a specified hash.
...@@ -230,28 +230,28 @@ public: ...@@ -230,28 +230,28 @@ public:
* *
* @return a token to cancel the listener later. * @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){ return listen(key, [cb](const std::vector<Sp<Value>>& vals, bool expired){
if (not expired) if (not expired)
return cb(vals); return cb(vals);
return true; return true;
}, std::forward<Value::Filter>(f), std::forward<Where>(w)); }, 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)); 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. * Inform the DHT of lower-layer connectivity changes.
* This will cause the DHT to assume a public IP address change. * This will cause the DHT to assume a public IP address change.
* The DHT will recontact neighbor nodes, re-register for listen ops etc. * The DHT will recontact neighbor nodes, re-register for listen ops etc.
*/ */
void connectivityChanged(sa_family_t); void connectivityChanged(sa_family_t) override;
void connectivityChanged() { void connectivityChanged() override {
reported_addr.clear(); reported_addr.clear();
connectivityChanged(AF_INET); connectivityChanged(AF_INET);
connectivityChanged(AF_INET6); connectivityChanged(AF_INET6);
...@@ -261,18 +261,18 @@ public: ...@@ -261,18 +261,18 @@ public:
* Get the list of good nodes for local storage saving purposes * Get the list of good nodes for local storage saving purposes
* The list is ordered to minimize the back-to-work delay. * 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; std::vector<ValuesExport> exportValues() const override;
void importValues(const std::vector<ValuesExport>&); void importValues(const std::vector<ValuesExport>&) override;
void saveState(const std::string& path) const; void saveState(const std::string& path) const;
void loadState(const std::string& path); 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 override;
std::string getStorageLog(const InfoHash&) const; std::string getStorageLog(const InfoHash&) const override;
std::string getRoutingTablesLog(sa_family_t) const; std::string getRoutingTablesLog(sa_family_t) const;
std::string getSearchesLog(sa_family_t) const; std::string getSearchesLog(sa_family_t) const;
...@@ -298,9 +298,9 @@ public: ...@@ -298,9 +298,9 @@ public:
return {total_store_size, total_values}; 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) {} void resubscribe(unsigned) {}
private: private:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment