0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-11 06:28:55 +02:00

ircd:Ⓜ️:vm: Consolidate duplicate eval condition branches.

This commit is contained in:
Jason Volk 2019-09-11 13:08:59 -07:00
parent fac2a1e070
commit 2527965c91
2 changed files with 8 additions and 6 deletions

View file

@ -1318,6 +1318,8 @@ ircd::m::vm::eval::count(const event::id &event_id)
}
else if(e.event_id == event_id)
++ret;
return true;
});
return ret;

View file

@ -884,6 +884,12 @@ ircd::m::vm::execute_pdu(eval &eval,
at<"type"_>(event)
};
if(eval::count(event_id) > 1)
throw error
{
fault::EXISTS, "Event is already being evaluated."
};
if(likely(!opts.replays) && m::exists(event_id))
throw error
{
@ -949,12 +955,6 @@ ircd::m::vm::execute_pdu(eval &eval,
assert(sequence::committed < sequence::get(eval));
assert(sequence::retired < sequence::get(eval));
sequence::committed = sequence::get(eval);
if(likely(!opts.replays) && unlikely(m::exists(event_id)))
throw error
{
fault::EXISTS, "Write commit rejected :Event has already been evaluated."
};
if(likely(opts.write))
write_prepare(eval, event);