0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-26 00:32:35 +01: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 closure &);
static void get(const string_view &server_name, const string_view &key_id, 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::tuple;
using super_type::operator=; using super_type::operator=;

View file

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