diff --git a/include/opendht/dht.h b/include/opendht/dht.h index dd6ae5faca64ca91bfb8800327570fcd03d81d85..8fed6bcc2eecf0836b6c709e0f2f2c3f20d30fbe 100644 --- a/include/opendht/dht.h +++ b/include/opendht/dht.h @@ -276,7 +276,7 @@ public: /** * Get locally stored data for the given key and value id. */ - std::shared_ptr<Value> getLocalById(const InfoHash& key, const Value::Id& vid) const; + std::shared_ptr<Value> getLocalById(const InfoHash& key, Value::Id vid) const; /** * Announce a value on all available protocols (IPv4, IPv6), and @@ -736,6 +736,12 @@ private: const std::vector<ValueStorage>& getValues() const { return values; } + std::shared_ptr<Value> getById(Value::Id vid) const { + for (auto& v : values) + if (v.data->id == vid) return v.data; + return {}; + } + std::vector<std::shared_ptr<Value>> get(Value::Filter f = {}) const { std::vector<std::shared_ptr<Value>> newvals {}; if (not f) newvals.reserve(values.size()); @@ -746,12 +752,6 @@ private: return newvals; } - std::shared_ptr<Value> get(Value::Id vid) const { - for (auto& v : values) - if (v.data->id == vid) return v.data; - return {}; - } - /** * Stores a new value in this storage, or replace a previous value * diff --git a/src/dht.cpp b/src/dht.cpp index 310d5f0ac4fa1f91e02670e3d92e07115b30b33c..55d7fafb86692d3c31018f95dca11ff3a42c8866 100644 --- a/src/dht.cpp +++ b/src/dht.cpp @@ -1679,11 +1679,11 @@ Dht::getLocal(const InfoHash& id, Value::Filter f) const } std::shared_ptr<Value> -Dht::getLocalById(const InfoHash& id, const Value::Id& vid) const +Dht::getLocalById(const InfoHash& id, Value::Id vid) const { auto s = findStorage(id); if (s != store.end()) - return s->get(vid); + return s->getById(vid); return {}; }