From 328a61df00a5d6052de067ec0b30a89fa0c8c6e0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com>
Date: Thu, 10 Dec 2015 13:13:42 -0500
Subject: [PATCH] dht: preserve value creation time

---
 include/opendht/dht.h | 2 +-
 src/dht.cpp           | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/opendht/dht.h b/include/opendht/dht.h
index 1375d9c7..3d32e946 100644
--- a/include/opendht/dht.h
+++ b/include/opendht/dht.h
@@ -882,7 +882,7 @@ private:
     }
 
     void storageAddListener(const InfoHash& id, const InfoHash& node, const sockaddr *from, socklen_t fromlen, uint16_t tid);
-    ValueStorage* storageStore(const InfoHash& id, const std::shared_ptr<Value>& value, time_point created=time_point::max());
+    ValueStorage* storageStore(const InfoHash& id, const std::shared_ptr<Value>& value, time_point created);
     void expireStorage();
     void storageChanged(Storage& st, ValueStorage&);
 
diff --git a/src/dht.cpp b/src/dht.cpp
index 3abec427..86972b7d 100644
--- a/src/dht.cpp
+++ b/src/dht.cpp
@@ -984,7 +984,7 @@ Dht::searchStep(Search& sr)
             if (in) {
                 DHT_WARN("[search %s IPv%c] [value %lu] storing locally",
                     sr.id.toString().c_str(), sr.af == AF_INET ? '4' : '6', vid);
-                storageStore(sr.id, a.value);
+                storageStore(sr.id, a.value, a.created);
             }
             for (auto& n : sr.nodes) {
                 if (not n.isSynced(now) or (n.candidate and t >= TARGET_NODES))
@@ -2807,7 +2807,7 @@ Dht::importValues(const std::vector<ValuesExport>& import)
                     DHT_DEBUG("Discarding expired value at %s", h.first.toString().c_str());
                     continue;
                 }
-                auto st = storageStore(h.first, std::make_shared<Value>(std::move(tmp_val)));
+                auto st = storageStore(h.first, std::make_shared<Value>(std::move(tmp_val)), val_time);
                 st->time = val_time;
             }
         } catch (const std::exception&) {
-- 
GitLab