mirror of
https://github.com/matrix-construct/construct
synced 2024-09-26 18:38:52 +02:00
modules/client/rooms/join: Fetch keys concurrently in bootstrap auth_chain eval.
This commit is contained in:
parent
e883f2a42b
commit
0f6e7f5745
2 changed files with 50 additions and 1 deletions
|
@ -147,6 +147,9 @@ bootstrap_send_join(const string_view &host,
|
|||
const m::event::id &,
|
||||
const json::object &event);
|
||||
|
||||
static void
|
||||
bootstrap_fetch_keys(const json::array &events);
|
||||
|
||||
static void
|
||||
bootstrap_eval_lazy_chain(const json::array &auth_chain);
|
||||
|
||||
|
@ -487,6 +490,8 @@ void
|
|||
bootstrap_eval_auth_chain(const json::array &auth_chain)
|
||||
try
|
||||
{
|
||||
bootstrap_fetch_keys(auth_chain);
|
||||
|
||||
m::vm::opts opts;
|
||||
opts.infolog_accept = true;
|
||||
opts.fetch = false;
|
||||
|
@ -571,6 +576,50 @@ bootstrap_eval_lazy_chain(const json::array &auth_chain)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
bootstrap_fetch_keys(const json::array &events)
|
||||
try
|
||||
{
|
||||
std::vector<m::v1::key::server_key> queries;
|
||||
queries.reserve(events.size());
|
||||
|
||||
for(const json::object &event : events)
|
||||
for(const auto &[server_name, signatures] : json::object(event["signatures"]))
|
||||
for(const auto &[key_id, signature] : json::object(signatures))
|
||||
queries.emplace_back(unquote(event.at("origin")), key_id);
|
||||
|
||||
std::sort(begin(queries), end(queries));
|
||||
queries.erase(std::unique(begin(queries), end(queries)), end(queries));
|
||||
|
||||
log::info
|
||||
{
|
||||
join_log, "Fetching %zu keys for %zu events...",
|
||||
queries.size(),
|
||||
events.size(),
|
||||
};
|
||||
|
||||
const size_t fetched
|
||||
{
|
||||
m::keys::fetch(queries)
|
||||
};
|
||||
|
||||
log::info
|
||||
{
|
||||
join_log, "Fetched %zu of %zu keys for %zu events",
|
||||
fetched,
|
||||
queries.size(),
|
||||
events.size(),
|
||||
};
|
||||
}
|
||||
catch(const std::exception &e)
|
||||
{
|
||||
log::error
|
||||
{
|
||||
join_log, "Error when fetching keys for %zu events :%s",
|
||||
events.size(),
|
||||
};
|
||||
}
|
||||
|
||||
std::tuple<json::object, unique_buffer<mutable_buffer>>
|
||||
bootstrap_send_join(const string_view &host,
|
||||
const m::room::id &room_id,
|
||||
|
|
|
@ -413,7 +413,7 @@ ircd::m::keys::get(const queries &queries,
|
|||
if(cached)
|
||||
continue;
|
||||
|
||||
if(server_name == my_host())
|
||||
if(my_host(server_name))
|
||||
{
|
||||
log::derror
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue