From 4aaeaff8fbf988ffb266ac84c0f91fd831d0bbc3 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Mon, 12 Mar 2018 19:34:54 -0700 Subject: [PATCH] ircd::m::vm: Add options for pre-checked event conformity or skip entirely. --- include/ircd/m/vm.h | 14 +++++++++++++- ircd/m/vm.cc | 9 ++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/include/ircd/m/vm.h b/include/ircd/m/vm.h index 9828a8793..188635ba5 100644 --- a/include/ircd/m/vm.h +++ b/include/ircd/m/vm.h @@ -95,9 +95,21 @@ struct ircd::m::vm::opts /// Broadcast to clients/servers bool notify {true}; - /// Mask of conformity failures to allow without error + /// False to allow a dirty conforms report (not recommended). + bool conforming {true}; + + /// Mask of conformity failures to allow without considering dirty. event::conforms non_conform; + /// If the event was already checked before the eval, set this to true + /// and include the report (see below). + bool conformed {false}; + + /// When conformed=true, this report will be included instead of generating + /// one during the eval. This is useful if a conformity check was already + /// done before eval. + event::conforms report; + /// Toggles whether event may be considered a "present event" and may /// update the optimized present state table of the room if it is proper. bool present {true}; diff --git a/ircd/m/vm.cc b/ircd/m/vm.cc index 946766a12..8fd5c13c6 100644 --- a/ircd/m/vm.cc +++ b/ircd/m/vm.cc @@ -209,12 +209,15 @@ enum ircd::m::vm::fault ircd::m::vm::eval::operator()(const event &event) try { - const event::conforms report + assert(opts); + const event::conforms &report { - event, opts->non_conform.report + opts->conforming && !opts->conformed? + event::conforms{event, opts->non_conform.report}: + opts->report }; - if(!report.clean()) + if(opts->conforming && !report.clean()) throw error { fault::INVALID, "Non-conforming event: %s", string(report)