0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-02 18:18:56 +02:00

ircd:Ⓜ️:vm::eval: Add find_pdu() to interface.

This commit is contained in:
Jason Volk 2019-07-20 17:21:27 -07:00
parent e589e89a2c
commit bcec03ce1a
2 changed files with 36 additions and 0 deletions

View file

@ -81,6 +81,8 @@ struct ircd::m::vm::eval
string_view room_version;
static bool for_each_pdu(const std::function<bool (const event &)> &);
static const event *find_pdu(const eval &, const event::id &);
static const event *find_pdu(const event::id &);
public:
operator const event::id::buf &() const;

View file

@ -1558,6 +1558,40 @@ const
return event_id;
}
const ircd::m::event *
ircd::m::vm::eval::find_pdu(const event::id &event_id)
{
const m::event *ret{nullptr};
for_each_pdu([&ret, &event_id]
(const m::event &event)
{
if(event.event_id != event_id)
return true;
ret = std::addressof(event);
return false;
});
return ret;
}
const ircd::m::event *
ircd::m::vm::eval::find_pdu(const eval &eval,
const event::id &event_id)
{
const m::event *ret{nullptr};
for(const auto &event : eval.pdus)
{
if(event.event_id != event_id)
continue;
ret = std::addressof(event);
break;
}
return ret;
}
bool
ircd::m::vm::eval::for_each_pdu(const std::function<bool (const event &)> &closure)
{