mirror of
https://github.com/matrix-construct/construct
synced 2024-11-29 10:12:39 +01:00
ircd:Ⓜ️:vm: Add canonization point prior to core eval.
This commit is contained in:
parent
d4cab12056
commit
02dc164d66
2 changed files with 26 additions and 1 deletions
|
@ -83,6 +83,7 @@ struct ircd::m::vm::eval
|
|||
uint64_t id {++id_ctr};
|
||||
uint64_t sequence {0};
|
||||
std::shared_ptr<db::txn> txn;
|
||||
unique_mutable_buffer buf;
|
||||
|
||||
vector_view<const m::event> pdus;
|
||||
const json::iov *issue {nullptr};
|
||||
|
|
|
@ -218,6 +218,30 @@ try
|
|||
*eval.opts
|
||||
};
|
||||
|
||||
assert(!eval.buf || size(eval.buf) >= event::MAX_SIZE);
|
||||
if(!opts.json_source && !eval.buf)
|
||||
eval.buf = unique_mutable_buffer
|
||||
{
|
||||
event::MAX_SIZE, 64
|
||||
};
|
||||
|
||||
const scope_restore event_source
|
||||
{
|
||||
mutable_cast(event).source,
|
||||
|
||||
// Canonize from some other serialized source.
|
||||
!opts.json_source && event.source?
|
||||
json::object(json::stringify(mutable_buffer{eval.buf}, event.source)):
|
||||
|
||||
// Canonize from no source; usually taken when my(event).
|
||||
// XXX elision conditions go here
|
||||
!opts.json_source?
|
||||
json::object(json::stringify(mutable_buffer{eval.buf}, event)):
|
||||
|
||||
// Use the input directly.
|
||||
event.source
|
||||
};
|
||||
|
||||
// Set a member to the room_id for convenient access, without stepping on
|
||||
// any room_id reference that exists there for whatever reason.
|
||||
const scope_restore eval_room_id
|
||||
|
@ -961,7 +985,7 @@ ircd::m::vm::write_append(eval &eval,
|
|||
m::dbs::write_opts wopts(opts.wopts);
|
||||
wopts.interpose = eval.txn.get();
|
||||
wopts.event_idx = eval.sequence;
|
||||
wopts.json_source = opts.json_source;
|
||||
wopts.json_source = true;
|
||||
|
||||
// Don't update or resolve the room head with this shit.
|
||||
const bool dummy_event
|
||||
|
|
Loading…
Reference in a new issue