mirror of
https://github.com/oxen-io/lokinet
synced 2023-12-14 06:53:00 +01:00
Merge pull request #1611 from majestrate/oxencore-fetch-list-if-stale-2021-04-26
limit service node list updates
This commit is contained in:
commit
38f0c8091b
2 changed files with 7 additions and 1 deletions
|
@ -45,6 +45,7 @@ namespace llarp
|
||||||
auto lokidCategory = m_lokiMQ->add_category("lokid", oxenmq::Access{oxenmq::AuthLevel::none});
|
auto lokidCategory = m_lokiMQ->add_category("lokid", oxenmq::Access{oxenmq::AuthLevel::none});
|
||||||
lokidCategory.add_request_command(
|
lokidCategory.add_request_command(
|
||||||
"get_peer_stats", [this](oxenmq::Message& m) { HandleGetPeerStats(m); });
|
"get_peer_stats", [this](oxenmq::Message& m) { HandleGetPeerStats(m); });
|
||||||
|
m_UpdatingList = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -83,7 +84,9 @@ namespace llarp
|
||||||
return; // bail
|
return; // bail
|
||||||
}
|
}
|
||||||
LogDebug("new block at hieght ", msg.data[0]);
|
LogDebug("new block at hieght ", msg.data[0]);
|
||||||
UpdateServiceNodeList(std::string{msg.data[1]});
|
// don't upadate on block notification if an update is pending
|
||||||
|
if (not m_UpdatingList)
|
||||||
|
UpdateServiceNodeList(std::string{msg.data[1]});
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -95,9 +98,11 @@ namespace llarp
|
||||||
request["active_only"] = true;
|
request["active_only"] = true;
|
||||||
if (not topblock.empty())
|
if (not topblock.empty())
|
||||||
request["poll_block_hash"] = topblock;
|
request["poll_block_hash"] = topblock;
|
||||||
|
m_UpdatingList = true;
|
||||||
Request(
|
Request(
|
||||||
"rpc.get_service_nodes",
|
"rpc.get_service_nodes",
|
||||||
[self = shared_from_this()](bool success, std::vector<std::string> data) {
|
[self = shared_from_this()](bool success, std::vector<std::string> data) {
|
||||||
|
self->m_UpdatingList = false;
|
||||||
if (not success)
|
if (not success)
|
||||||
{
|
{
|
||||||
LogWarn("failed to update service node list");
|
LogWarn("failed to update service node list");
|
||||||
|
|
|
@ -76,6 +76,7 @@ namespace llarp
|
||||||
LMQ_ptr m_lokiMQ;
|
LMQ_ptr m_lokiMQ;
|
||||||
|
|
||||||
AbstractRouter* const m_Router;
|
AbstractRouter* const m_Router;
|
||||||
|
std::atomic<bool> m_UpdatingList;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace rpc
|
} // namespace rpc
|
||||||
|
|
Loading…
Reference in a new issue