mirror of
https://github.com/matrix-construct/construct
synced 2024-11-26 00:32:35 +01:00
ircd:Ⓜ️:vm::eval: Add find_pdu() to interface.
This commit is contained in:
parent
e589e89a2c
commit
bcec03ce1a
2 changed files with 36 additions and 0 deletions
|
@ -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;
|
||||
|
|
34
ircd/m.cc
34
ircd/m.cc
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue