diff --git a/include/ircd/m/event.h b/include/ircd/m/event.h index faad2ccf4..ed9a806a2 100644 --- a/include/ircd/m/event.h +++ b/include/ircd/m/event.h @@ -25,6 +25,8 @@ namespace ircd::m // [GET] bool exists(const id::event &); + bool bad(const id::event &, uint64_t &); + bool bad(const id::event &); // Depth comparison; expect unstable sorting. bool operator<(const event &, const event &); diff --git a/ircd/m/event.cc b/ircd/m/event.cc index 6b369d354..febb462ce 100644 --- a/ircd/m/event.cc +++ b/ircd/m/event.cc @@ -289,6 +289,41 @@ ircd::m::operator<(const event &a, const event &b) return at<"depth"_>(a) < at<"depth"_>(b); } +bool +ircd::m::bad(const id::event &event_id) +{ + auto &column + { + dbs::event_bad + }; + + return has(column, event_id); +} + +bool +ircd::m::bad(const id::event &event_id, + uint64_t &idx) +{ + auto &column + { + dbs::event_bad + }; + + bool ret; + const string_view value + { + read(column, event_id, ret, mutable_buffer + { + reinterpret_cast(&idx), sizeof(idx) + }) + }; + + if(!value) + idx = uint64_t(-1); + + return ret; +} + bool ircd::m::exists(const id::event &event_id) {