mirror of
https://github.com/matrix-construct/construct
synced 2024-12-27 07:54:05 +01:00
ircd:Ⓜ️:vm: Add more options for fine-grained hook call control during eval.
This commit is contained in:
parent
11818f6c3e
commit
f216f60583
2 changed files with 23 additions and 6 deletions
|
@ -103,7 +103,13 @@ struct ircd::m::vm::opts
|
||||||
/// Make writes to database
|
/// Make writes to database
|
||||||
bool write {true};
|
bool write {true};
|
||||||
|
|
||||||
/// Apply effects of the eval
|
/// Make fetches or false to bypass fetch stage.
|
||||||
|
bool fetch {true};
|
||||||
|
|
||||||
|
/// Call eval hooks or false to bypass this stage.
|
||||||
|
bool eval {true};
|
||||||
|
|
||||||
|
/// Apply effects of this event or false to bypass this stage.
|
||||||
bool effects {true};
|
bool effects {true};
|
||||||
|
|
||||||
/// Broadcast to clients/servers. When true, individual notify options
|
/// Broadcast to clients/servers. When true, individual notify options
|
||||||
|
|
|
@ -596,7 +596,9 @@ enum ircd::m::vm::fault
|
||||||
ircd::m::vm::_eval_edu(eval &eval,
|
ircd::m::vm::_eval_edu(eval &eval,
|
||||||
const event &event)
|
const event &event)
|
||||||
{
|
{
|
||||||
eval_hook(event, eval);
|
if(eval.opts->eval)
|
||||||
|
eval_hook(event, eval);
|
||||||
|
|
||||||
return fault::ACCEPT;
|
return fault::ACCEPT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -625,7 +627,13 @@ ircd::m::vm::_eval_pdu(eval &eval,
|
||||||
at<"type"_>(event)
|
at<"type"_>(event)
|
||||||
};
|
};
|
||||||
|
|
||||||
if(!opts.replays && exists(event_id)) //TODO: exclusivity
|
const bool already_exists
|
||||||
|
{
|
||||||
|
exists(event_id)
|
||||||
|
};
|
||||||
|
|
||||||
|
//TODO: ABA
|
||||||
|
if(already_exists && !opts.replays)
|
||||||
throw error
|
throw error
|
||||||
{
|
{
|
||||||
fault::EXISTS, "Event has already been evaluated."
|
fault::EXISTS, "Event has already been evaluated."
|
||||||
|
@ -646,13 +654,16 @@ ircd::m::vm::_eval_pdu(eval &eval,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Obtain sequence number here
|
// Obtain sequence number here
|
||||||
eval.sequence = ++vm::current_sequence;
|
if(opts.write)
|
||||||
|
eval.sequence = ++vm::current_sequence;
|
||||||
|
|
||||||
// Fetch dependencies
|
// Fetch dependencies
|
||||||
fetch_hook(event, eval);
|
if(opts.fetch)
|
||||||
|
fetch_hook(event, eval);
|
||||||
|
|
||||||
// Evaluation by module hooks
|
// Evaluation by module hooks
|
||||||
eval_hook(event, eval);
|
if(opts.eval)
|
||||||
|
eval_hook(event, eval);
|
||||||
|
|
||||||
if(!opts.write)
|
if(!opts.write)
|
||||||
return fault::ACCEPT;
|
return fault::ACCEPT;
|
||||||
|
|
Loading…
Reference in a new issue