From ca45e8490870e11c5044367c52db05dcf6b15072 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Fri, 4 May 2018 16:13:10 -0700 Subject: [PATCH] ircd::m: Add bad(event_id) query interface. --- include/ircd/m/event.h | 2 ++ ircd/m/event.cc | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) 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) {