mirror of
https://github.com/matrix-construct/construct
synced 2024-06-02 18:18:56 +02:00
ircd:Ⓜ️:vm: Refactor various fetch related options.
This commit is contained in:
parent
56dd0ed8e7
commit
e3b1be2910
|
@ -127,8 +127,9 @@ enum ircd::m::vm::fault
|
|||
{
|
||||
ACCEPT = 0x00, ///< No fault.
|
||||
EXISTS = 0x01, ///< Replaying existing event. (#ex)
|
||||
INVALID = 0x02, ///< Non-conforming event format. (#ud)
|
||||
GENERAL = 0x04, ///< General protection fault. (#gp)
|
||||
GENERAL = 0x02, ///< General protection fault. (#gp)
|
||||
INVALID = 0x04, ///< Non-conforming event format. (#ud)
|
||||
AUTH = 0x08, ///< Auth rules violation. (#av)
|
||||
STATE = 0x10, ///< Required state is missing (#st)
|
||||
EVENT = 0x20, ///< Eval requires addl events in the ef register (#ef)
|
||||
INTERRUPT = 0x40, ///< ctx::interrupted (#nmi)
|
||||
|
@ -219,47 +220,48 @@ struct ircd::m::vm::opts
|
|||
// Verify the origin signature
|
||||
bool verify {true};
|
||||
|
||||
/// Performs a query during the fetch stage to check if the event's auth
|
||||
/// exists locally. This query is required for any fetching to be
|
||||
/// possible.
|
||||
bool fetch_auth_check {true};
|
||||
|
||||
/// Whether to automatically fetch the auth events when they do not exist.
|
||||
bool fetch_auth {true};
|
||||
|
||||
/// Waits for auth events to be processed before continuing. Without
|
||||
/// waiting, if any auth events are missing fault::EVENT is thrown.
|
||||
/// Note that fault::AUTH is only thrown for authentication failures
|
||||
/// while fault::EVENT is when the data is missing.
|
||||
bool fetch_auth_wait {true};
|
||||
|
||||
/// Performs a query during the fetch stage to check if the room's state
|
||||
/// exists locally. This query is required for any fetching to be
|
||||
/// possible.
|
||||
bool state_check_exists {true};
|
||||
bool fetch_state_check {true};
|
||||
|
||||
/// Whether to automatically fetch the room state when there is no state
|
||||
/// for the room found on the this server.
|
||||
bool state_fetch {true};
|
||||
/// or incomplete state for the room found on the this server.
|
||||
bool fetch_state {true};
|
||||
|
||||
/// Waits for a condition where fault::STATE would not be thrown, depending
|
||||
/// on the below options. In other words, the context blocks until the
|
||||
/// system has fetched and resolved the state from remote parties.
|
||||
bool state_wait {true};
|
||||
|
||||
/// Throws fault::STATE if the room's state does not exist.
|
||||
bool state_must_exist {true};
|
||||
|
||||
/// Whether to automatically fetch and evaluate the auth chain for the
|
||||
/// event; effective when there is no state for this room on the server.
|
||||
bool auth_chain_fetch {true};
|
||||
/// Waits for a condition where fault::STATE would not be thrown before
|
||||
/// continuing with the eval.
|
||||
bool fetch_state_wait {true};
|
||||
|
||||
/// Performs a query during the fetch stage to check if the referenced
|
||||
/// prev_events exist locally. This query is required for any fetching
|
||||
/// to be possible.
|
||||
bool prev_check_exists {true};
|
||||
bool fetch_prev_check {true};
|
||||
|
||||
/// Dispatches a fetch operation when a prev_event does not exist locally.
|
||||
bool prev_fetch {true};
|
||||
bool fetch_prev {true};
|
||||
|
||||
/// Waits for a condition where fault::EVENT would not be thrown, depending
|
||||
/// on the below options. In other words, the context blocks until one/all
|
||||
/// prev_events has been evaluated. This is required for ordered evaluation.
|
||||
bool prev_wait {false};
|
||||
/// Waits for prev_events have been acquired before continuing with this
|
||||
/// evaluation.
|
||||
bool fetch_prev_wait {true};
|
||||
|
||||
/// Throws fault::EVENT if *none* of the prev_events exist locally,
|
||||
/// regardless of whether fetching was initiated for them.
|
||||
bool prev_must_exist {false};
|
||||
|
||||
/// Throws fault::EVENT if *any* of the prev_events do not exist locally,
|
||||
/// in contrast to prev_must_exist.
|
||||
bool prev_must_all_exist {false};
|
||||
/// Throws fault::EVENT if *any* of the prev_events do not exist locally.
|
||||
/// This is used to enforce that all references have been acquired.
|
||||
bool fetch_prev_all {false};
|
||||
|
||||
/// Evaluators can set this value to optimize the creation of the database
|
||||
/// transaction where the event will be stored. This value should be set
|
||||
|
|
19
ircd/m.cc
19
ircd/m.cc
|
@ -1214,8 +1214,10 @@ ircd::m::vm::http_code(const fault &code)
|
|||
case fault::ACCEPT: return http::OK;
|
||||
case fault::EXISTS: return http::CONFLICT;
|
||||
case fault::INVALID: return http::BAD_REQUEST;
|
||||
case fault::GENERAL: return http::FORBIDDEN;
|
||||
case fault::GENERAL: return http::UNAUTHORIZED;
|
||||
case fault::AUTH: return http::FORBIDDEN;
|
||||
case fault::STATE: return http::NOT_FOUND;
|
||||
case fault::EVENT: return http::NOT_FOUND;
|
||||
default: return http::INTERNAL_SERVER_ERROR;
|
||||
}
|
||||
}
|
||||
|
@ -1225,13 +1227,14 @@ ircd::m::vm::reflect(const enum fault &code)
|
|||
{
|
||||
switch(code)
|
||||
{
|
||||
case fault::ACCEPT: return "ACCEPT";
|
||||
case fault::EXISTS: return "EXISTS";
|
||||
case fault::INVALID: return "INVALID";
|
||||
case fault::GENERAL: return "GENERAL";
|
||||
case fault::EVENT: return "EVENT";
|
||||
case fault::STATE: return "STATE";
|
||||
case fault::INTERRUPT: return "INTERRUPT";
|
||||
case fault::ACCEPT: return "#ACCEPT";
|
||||
case fault::EXISTS: return "#EXISTS";
|
||||
case fault::GENERAL: return "#GENERAL";
|
||||
case fault::INVALID: return "#INVALID";
|
||||
case fault::AUTH: return "#AUTH";
|
||||
case fault::EVENT: return "#EVENT";
|
||||
case fault::STATE: return "#STATE";
|
||||
case fault::INTERRUPT: return "#INTERRUPT";
|
||||
}
|
||||
|
||||
return "??????";
|
||||
|
|
|
@ -240,7 +240,6 @@ bootstrap(const string_view &host,
|
|||
};
|
||||
|
||||
m::vm::copts opts;
|
||||
opts.history = false;
|
||||
opts.infolog_accept = true;
|
||||
const m::event::id::buf event_id
|
||||
{
|
||||
|
|
|
@ -6954,7 +6954,6 @@ console_cmd__eval__file(opt &out, const string_view &line)
|
|||
|
||||
m::vm::opts opts;
|
||||
opts.non_conform.set(m::event::conforms::MISSING_PREV_STATE);
|
||||
opts.prev_check_exists = false;
|
||||
opts.notify = false;
|
||||
opts.verify = false;
|
||||
m::vm::eval eval
|
||||
|
@ -11122,11 +11121,6 @@ console_cmd__fed__sync(opt &out, const string_view &line)
|
|||
|
||||
m::vm::opts vmopts;
|
||||
vmopts.non_conform.set(m::event::conforms::MISSING_PREV_STATE);
|
||||
vmopts.prev_check_exists = false;
|
||||
vmopts.state_must_exist = false;
|
||||
vmopts.history = false;
|
||||
vmopts.verify = false;
|
||||
vmopts.notify = false;
|
||||
vmopts.debuglog_accept = true;
|
||||
vmopts.nothrows = -1;
|
||||
m::vm::eval eval
|
||||
|
@ -11231,11 +11225,6 @@ console_cmd__fed__state(opt &out, const string_view &line)
|
|||
|
||||
m::vm::opts vmopts;
|
||||
vmopts.non_conform.set(m::event::conforms::MISSING_PREV_STATE);
|
||||
vmopts.prev_check_exists = false;
|
||||
vmopts.state_must_exist = false;
|
||||
vmopts.verify = false;
|
||||
vmopts.history = false;
|
||||
vmopts.notify = false;
|
||||
m::vm::eval eval
|
||||
{
|
||||
vmopts
|
||||
|
@ -11390,11 +11379,6 @@ console_cmd__fed__backfill(opt &out, const string_view &line)
|
|||
|
||||
m::vm::opts vmopts;
|
||||
vmopts.non_conform.set(m::event::conforms::MISSING_PREV_STATE);
|
||||
vmopts.prev_check_exists = false;
|
||||
vmopts.state_must_exist = false;
|
||||
vmopts.history = false;
|
||||
vmopts.verify = false;
|
||||
vmopts.notify = false;
|
||||
vmopts.room_head = false;
|
||||
vmopts.room_refs = true;
|
||||
m::vm::eval eval
|
||||
|
@ -11569,12 +11553,6 @@ console_cmd__fed__event(opt &out, const string_view &line)
|
|||
|
||||
m::vm::opts vmopts;
|
||||
vmopts.non_conform.set(m::event::conforms::MISSING_PREV_STATE);
|
||||
vmopts.prev_check_exists = true;
|
||||
vmopts.prev_wait = true;
|
||||
vmopts.state_must_exist = true;
|
||||
vmopts.history = false;
|
||||
vmopts.notify = false;
|
||||
//vmopts.verify = false;
|
||||
m::vm::eval eval
|
||||
{
|
||||
event, vmopts
|
||||
|
|
|
@ -147,6 +147,7 @@ put__invite(client &client,
|
|||
// already been made for this request.
|
||||
const unwind::nominal::assertion na;
|
||||
vmopts.nothrows = -1;
|
||||
vmopts.fetch_prev_check = false;
|
||||
|
||||
m::vm::eval
|
||||
{
|
||||
|
|
|
@ -76,8 +76,6 @@ handle_pdus(client &client,
|
|||
vmopts.non_conform.set(m::event::conforms::MISSING_PREV_STATE);
|
||||
vmopts.nothrows = -1U;
|
||||
vmopts.infolog_accept = true;
|
||||
vmopts.warnlog |= m::vm::fault::STATE;
|
||||
vmopts.errorlog &= ~m::vm::fault::STATE;
|
||||
m::vm::eval eval
|
||||
{
|
||||
pdus, vmopts
|
||||
|
|
|
@ -244,10 +244,6 @@ ircd::m::fetch::auth_chain(const room &room,
|
|||
m::vm::opts vmopts;
|
||||
vmopts.non_conform.set(m::event::conforms::MISSING_PREV_STATE);
|
||||
vmopts.infolog_accept = true;
|
||||
vmopts.prev_check_exists = false;
|
||||
vmopts.warnlog |= m::vm::fault::STATE;
|
||||
vmopts.warnlog &= ~m::vm::fault::EXISTS;
|
||||
vmopts.errorlog &= ~m::vm::fault::STATE;
|
||||
for(const auto &event : events)
|
||||
m::vm::eval
|
||||
{
|
||||
|
@ -643,6 +639,10 @@ try
|
|||
|
||||
m::vm::opts opts;
|
||||
opts.infolog_accept = true;
|
||||
opts.fetch_prev_check = false;
|
||||
opts.fetch_state_wait = false;
|
||||
opts.fetch_auth_wait = false;
|
||||
opts.fetch_prev_wait = false;
|
||||
m::vm::eval
|
||||
{
|
||||
m::event{event}, opts
|
||||
|
|
|
@ -896,7 +896,7 @@ ircd::m::vm::write_append(eval &eval,
|
|||
|
||||
const bool require_head
|
||||
{
|
||||
opts.state_must_exist || opts.history
|
||||
opts.fetch_state_check || opts.history
|
||||
};
|
||||
|
||||
const id::event::buf head
|
||||
|
|
Loading…
Reference in a new issue