proxy: count permanent put values by hash in stats

This commit is contained in:
Sébastien Blin authored and Adrien Béraud committed 2020-05-24 01:25:31 -04:00
1 parent a2afb5bb31
commit 9292c1116c
3 files changed
+14 -10

No files matched your search

+6 -2
View File
@@ -555,6 +555,10 @@ DhtProxyServer::updateStats(std::shared_ptr<NodeInfo> info) const
#ifdef OPENDHT_PUSH_NOTIFICATIONS
stats.pushListenersCount = pushListeners_.size();
#endif
stats.totalPermanentPuts = 0;
std::for_each(puts_.begin(), puts_.end(), [&stats](const auto& put) {
stats.totalPermanentPuts += put.second.puts.size();
});
stats.putCount = puts_.size();
stats.listenCount = listeners_.size();
stats.nodeInfo = std::move(info);
@@ -1142,8 +1146,8 @@ DhtProxyServer::put(restinio::request_handle_t request,
auto& sPuts = puts_[infoHash];
if (value->id == Value::INVALID_ID) {
for (auto& pp : sPuts.puts) {
if (pp.second.pushToken == pushToken
and pp.second.clientId == clientId
if (pp.second.pushToken == pushToken
and pp.second.clientId == clientId
and pp.second.value->contentEquals(*value))
{
pp.second.expireTimer->expires_at(timeout);