From e5b56cc0a524ffa4e11a2ed53762012553120cc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Blin?= Date: Wed, 9 Jan 2019 14:29:36 -0500 Subject: [PATCH] dht: link to tellListenerRefreshed When a permanent put is refreshed, the node has to tell to its remote listeners that the value is refreshed. --- src/dht.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/dht.cpp b/src/dht.cpp index b8451197..3a97ea60 100644 --- a/src/dht.cpp +++ b/src/dht.cpp @@ -2384,6 +2384,23 @@ Dht::storageRefresh(const InfoHash& id, Value::Id vid) const auto& now = scheduler.time(); auto s = store.find(id); if (s != store.end()) { + // Values like for a permanent put can be refreshed. So, inform remote listeners that the value + // need to be refreshed + auto& st = s->second; + if (not st.listeners.empty()) { + DHT_LOG.d(id, "[store %s] %lu remote listeners", id.toString().c_str(), st.listeners.size()); + std::vector ids = {vid}; + for (const auto& node_listeners : st.listeners) { + for (const auto& l : node_listeners.second) { + DHT_LOG.w(id, node_listeners.first->id, "[store %s] [node %s] sending refresh", + id.toString().c_str(), + node_listeners.first->toString().c_str()); + Blob ntoken = makeToken(node_listeners.first->getAddr(), false); + network_engine.tellListenerRefreshed(node_listeners.first, l.first, id, ntoken, ids); + } + } + } + auto expiration = s->second.refresh(now, vid, types); if (expiration != time_point::max()) scheduler.add(expiration, std::bind(&Dht::expireStorage, this, id));