From 7ca2e8797d5dda6a689c380cc44167c9a8f67b61 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Fri, 4 May 2018 15:14:19 -0700 Subject: [PATCH] ircd::m::dbs: Add interface to manipulate the blacklist column. --- include/ircd/m/dbs.h | 1 + ircd/m/dbs.cc | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/include/ircd/m/dbs.h b/include/ircd/m/dbs.h index 0925e9c5b..40ae5dcd8 100644 --- a/include/ircd/m/dbs.h +++ b/include/ircd/m/dbs.h @@ -60,6 +60,7 @@ namespace ircd::m::dbs // [SET (txn)] Basic write suite string_view write(db::txn &, const event &, const write_opts &); + void blacklist(db::txn &, const event::id &, const write_opts &); } struct ircd::m::dbs::write_opts diff --git a/ircd/m/dbs.cc b/ircd/m/dbs.cc index 4c4d59e46..54a2930f9 100644 --- a/ircd/m/dbs.cc +++ b/ircd/m/dbs.cc @@ -102,6 +102,24 @@ namespace ircd::m::dbs static string_view _index_ephem(db::txn &, const event &, const write_opts &); } +void +ircd::m::dbs::blacklist(db::txn &txn, + const event::id &event_id, + const write_opts &opts) +{ + db::txn::append + { + txn, event_bad, + { + opts.op, + string_view{event_id}, + opts.idx != uint64_t(-1) && opts.op == db::op::SET? + byte_view(opts.idx): + string_view{} + } + }; +} + ircd::string_view ircd::m::dbs::write(db::txn &txn, const event &event,