mirror of
https://github.com/matrix-construct/construct
synced 2024-12-26 15:33:54 +01:00
ircd:Ⓜ️ Add bad(event_id) query interface.
This commit is contained in:
parent
f34ebec1cf
commit
ca45e84908
2 changed files with 37 additions and 0 deletions
|
@ -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 &);
|
||||
|
|
|
@ -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<char *>(&idx), sizeof(idx)
|
||||
})
|
||||
};
|
||||
|
||||
if(!value)
|
||||
idx = uint64_t(-1);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::m::exists(const id::event &event_id)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue