diff --git a/include/ircd/m/room/events.h b/include/ircd/m/room/events.h index e8b7c13b9..ea4de2b3d 100644 --- a/include/ircd/m/room/events.h +++ b/include/ircd/m/room/events.h @@ -80,10 +80,10 @@ struct ircd::m::room::events auto &operator--() { return ++it; } // Fetch the actual event data at the iterator's position - const m::event &operator*(); - const m::event *operator->() { return &operator*(); } - const m::event &fetch(std::nothrow_t); + const m::event &fetch(std::nothrow_t, bool *valid = nullptr); const m::event &fetch(); + const m::event &operator*() { return fetch(std::nothrow); } + const m::event *operator->() { return &operator*(); } // Prefetch the actual event data at the iterator's position (async) bool prefetch(const string_view &event_prop); diff --git a/matrix/room_events.cc b/matrix/room_events.cc index 56dbede09..d6655981a 100644 --- a/matrix/room_events.cc +++ b/matrix/room_events.cc @@ -321,18 +321,20 @@ ircd::m::room::events::fetch() } const ircd::m::event & -ircd::m::room::events::fetch(std::nothrow_t) +ircd::m::room::events::fetch(std::nothrow_t, + bool *const valid_) { - m::seek(std::nothrow, _event, event_idx()); + const bool valid + { + m::seek(std::nothrow, _event, event_idx()) + }; + + if(valid_) + *valid_ = valid; + return _event; } -const ircd::m::event & -ircd::m::room::events::operator*() -{ - return fetch(std::nothrow); -}; - bool ircd::m::room::events::preseek(const uint64_t &depth) {