0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-05-29 00:03:45 +02:00

ircd:Ⓜ️:keys: Improve key query and cache loop.

This commit is contained in:
Jason Volk 2019-06-23 16:22:40 -07:00
parent c2f86a8094
commit 37760fe251
2 changed files with 8 additions and 20 deletions

View file

@ -59,7 +59,7 @@ struct ircd::m::keys
static void get(const string_view &server_name, const closure &);
static void get(const string_view &server_name, const string_view &key_id, const closure &);
static bool query(const string_view &query_server, const queries &, const closure_bool &);
static void query(const string_view &query_server, const queries &, const closure_bool &);
using super_type::tuple;
using super_type::operator=;

View file

@ -140,7 +140,7 @@ ircd::m::keys_query_timeout
{ "default", 20000L }
};
bool
void
IRCD_MODULE_EXPORT
ircd::m::keys::query(const string_view &query_server,
const queries &queries,
@ -169,36 +169,24 @@ try
request
};
for(const json::object &key_ : response) try
for(const json::object &key : response) try
{
const m::keys &key
{
key_
};
verify(m::keys{key});
if(!closure(key))
continue;
verify(key);
log::debug
{
m::log, "Verified keys for '%s' from '%s'",
at<"server_name"_>(key),
query_server
};
if(!closure(key_))
return false;
cache::set(key);
}
catch(const std::exception &e)
{
log::derror
{
"Failed to verify keys for '%s' from '%s' :%s",
key_.get("server_name"),
key.get("server_name"),
query_server,
e.what()
};
}
return true;
}
catch(const ctx::timeout &e)
{