mirror of
https://github.com/matrix-construct/construct
synced 2025-01-13 08:23:56 +01:00
ircd:Ⓜ️:dbs: Fix causality violation; prevent queries to the future.
This commit is contained in:
parent
a11a5613bb
commit
563f833ab3
3 changed files with 13 additions and 7 deletions
|
@ -405,6 +405,7 @@ ircd::m::dbs::find_event_idx(const vector_view<event::idx> &idx,
|
|||
for(size_t i(0); i < num; ++i)
|
||||
{
|
||||
idx[i] = wopts.interpose->val(db::op::SET, "_event_idx", event_id[i], 0UL);
|
||||
assert(!idx[i] || idx[i] >= vm::sequence::retired);
|
||||
ret += idx[i] != 0;
|
||||
}
|
||||
|
||||
|
@ -421,6 +422,7 @@ ircd::m::dbs::find_event_idx(const vector_view<event::idx> &idx,
|
|||
for(size_t i(0); i < num; ++i)
|
||||
{
|
||||
idx[i] = m::index(std::nothrow, event_id[i]);
|
||||
assert(idx[i] < vm::sequence::retired);
|
||||
ret += idx[i] != 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -219,11 +219,14 @@ ircd::m::dbs::_index_event_refs_prev(db::txn &txn,
|
|||
event::id prev_id[count];
|
||||
event::idx prev_idx[count];
|
||||
for(size_t i(0); i < count; ++i)
|
||||
prev_id[i] = prev.prev_event(i);
|
||||
prev_id[i] = prev.prev_event(i),
|
||||
prev_idx[i] = 0;
|
||||
|
||||
const auto found
|
||||
auto _opts(opts);
|
||||
_opts.interpose = {};
|
||||
const size_t found
|
||||
{
|
||||
find_event_idx({prev_idx, count}, {prev_id, count}, opts)
|
||||
find_event_idx({prev_idx, count}, {prev_id, count}, _opts)
|
||||
};
|
||||
|
||||
for(size_t i(0); i < count; ++i)
|
||||
|
@ -245,9 +248,11 @@ ircd::m::dbs::_index_event_refs_prev(db::txn &txn,
|
|||
continue;
|
||||
}
|
||||
|
||||
thread_local char buf[EVENT_REFS_KEY_MAX_SIZE];
|
||||
assert(opts.event_idx != 0 && prev_idx[i] != 0);
|
||||
assert(opts.event_idx != prev_idx[i]);
|
||||
assert(prev_idx[i] < opts.event_idx);
|
||||
assert(prev_idx[i] <= vm::sequence::retired);
|
||||
assert(prev_idx[i] != 0 && opts.event_idx != 0);
|
||||
thread_local char buf[EVENT_REFS_KEY_MAX_SIZE];
|
||||
const string_view &key
|
||||
{
|
||||
event_refs_key(buf, prev_idx[i], ref::NEXT, opts.event_idx)
|
||||
|
|
|
@ -76,8 +76,7 @@ try
|
|||
bool need_top_head{opts.need_top_head};
|
||||
bool need_my_head{opts.need_my_head};
|
||||
ssize_t limit(opts.limit);
|
||||
head.for_each([&]
|
||||
(const event::idx &event_idx, const event::id &event_id)
|
||||
head.for_each([&](const event::idx &event_idx, const event::id &event_id)
|
||||
{
|
||||
// Determine the depth for metrics
|
||||
const int64_t depth
|
||||
|
|
Loading…
Reference in a new issue