mirror of
https://github.com/matrix-construct/construct
synced 2024-12-28 00:14:07 +01:00
modules/m_vm_fetch: Use m::fetch interface for auth chain.
This commit is contained in:
parent
8f29d519c1
commit
11f1038737
1 changed files with 23 additions and 20 deletions
|
@ -13,7 +13,7 @@ namespace ircd::m::vm::fetch
|
||||||
struct evaltab;
|
struct evaltab;
|
||||||
|
|
||||||
static void hook_handle_prev(const event &, vm::eval &, evaltab &, const room &);
|
static void hook_handle_prev(const event &, vm::eval &, evaltab &, const room &);
|
||||||
static void auth_chain(const room &, const net::hostport &);
|
static void auth_chain(const room &, const string_view &remote);
|
||||||
static void hook_handle_auth(const event &, vm::eval &, evaltab &, const room &);
|
static void hook_handle_auth(const event &, vm::eval &, evaltab &, const room &);
|
||||||
static void hook_handle(const event &, vm::eval &);
|
static void hook_handle(const event &, vm::eval &);
|
||||||
|
|
||||||
|
@ -205,45 +205,48 @@ ircd::m::vm::fetch::hook_handle_auth(const event &event,
|
||||||
|
|
||||||
void
|
void
|
||||||
ircd::m::vm::fetch::auth_chain(const room &room,
|
ircd::m::vm::fetch::auth_chain(const room &room,
|
||||||
const net::hostport &remote)
|
const string_view &remote)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
thread_local char rembuf[64];
|
|
||||||
log::debug
|
log::debug
|
||||||
{
|
{
|
||||||
log, "Fetching auth chain for %s in %s from %s",
|
log, "Fetching auth chain for %s in %s (hint: %s)",
|
||||||
string_view{room.event_id},
|
string_view{room.event_id},
|
||||||
string_view{room.room_id},
|
string_view{room.room_id},
|
||||||
string(rembuf, remote),
|
remote,
|
||||||
};
|
};
|
||||||
|
|
||||||
m::v1::event_auth::opts opts;
|
m::fetch::opts opts;
|
||||||
opts.remote = remote;
|
opts.op = m::fetch::op::auth;
|
||||||
opts.dynamic = true;
|
opts.room_id = room.room_id;
|
||||||
const unique_buffer<mutable_buffer> buf
|
opts.event_id = room.event_id;
|
||||||
|
opts.hint = remote;
|
||||||
|
auto future
|
||||||
{
|
{
|
||||||
16_KiB
|
m::fetch::start(opts)
|
||||||
};
|
};
|
||||||
|
|
||||||
m::v1::event_auth request
|
const auto result
|
||||||
{
|
{
|
||||||
room.room_id, room.event_id, buf, std::move(opts)
|
future.get(seconds(auth_timeout))
|
||||||
};
|
};
|
||||||
|
|
||||||
request.wait(seconds(auth_timeout));
|
const json::object response
|
||||||
request.get();
|
|
||||||
const json::array events
|
|
||||||
{
|
{
|
||||||
request
|
result
|
||||||
|
};
|
||||||
|
|
||||||
|
const json::array &auth_chain
|
||||||
|
{
|
||||||
|
response["auth_chain"]
|
||||||
};
|
};
|
||||||
|
|
||||||
log::debug
|
log::debug
|
||||||
{
|
{
|
||||||
log, "Evaluating %zu auth events in chain for %s in %s from %s",
|
log, "Evaluating %zu auth events in chain for %s in %s",
|
||||||
events.size(),
|
auth_chain.size(),
|
||||||
string_view{room.event_id},
|
string_view{room.event_id},
|
||||||
string_view{room.room_id},
|
string_view{room.room_id},
|
||||||
string(rembuf, remote),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
m::vm::opts vmopts;
|
m::vm::opts vmopts;
|
||||||
|
@ -253,7 +256,7 @@ try
|
||||||
vmopts.warnlog &= ~vm::fault::EXISTS;
|
vmopts.warnlog &= ~vm::fault::EXISTS;
|
||||||
m::vm::eval
|
m::vm::eval
|
||||||
{
|
{
|
||||||
events, vmopts
|
auth_chain, vmopts
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
catch(const std::exception &e)
|
catch(const std::exception &e)
|
||||||
|
|
Loading…
Reference in a new issue