mirror of
https://github.com/matrix-construct/construct
synced 2024-12-26 15:33:54 +01:00
ircd:Ⓜ️:room::state::space: Improve interface; fixes.
This commit is contained in:
parent
bb36a2c398
commit
b5a61a7a6b
3 changed files with 9 additions and 20 deletions
|
@ -11,7 +11,11 @@
|
|||
#pragma once
|
||||
#define HAVE_IRCD_M_ROOM_STATE_SPACE_H
|
||||
|
||||
/// Interface to all room states.
|
||||
/// Interface to all room states. This is a super-dimension of m::room::state.
|
||||
/// This contains all state events without overwriting them; we refer to this
|
||||
/// as the state-space. We use this interface as a tool to reconstruct the
|
||||
/// state of the room at the point of an event in the past; or efficiently
|
||||
/// rebuild the present state table after inconsistencies, etc.
|
||||
///
|
||||
struct ircd::m::room::state::space
|
||||
{
|
||||
|
@ -20,6 +24,7 @@ struct ircd::m::room::state::space
|
|||
|
||||
m::room room;
|
||||
|
||||
public:
|
||||
bool for_each(const string_view &type, const string_view &state_key, const int64_t &depth, const closure &) const;
|
||||
bool for_each(const string_view &type, const string_view &state_key, const closure &) const;
|
||||
bool for_each(const string_view &type, const closure &) const;
|
||||
|
|
|
@ -3116,7 +3116,6 @@ ircd::m::dbs::room_state_space_key(const mutable_buffer &out_,
|
|||
|
||||
consume(out, copy(out, "\0"_sv));
|
||||
consume(out, copy(out, state_key));
|
||||
consume(out, copy(out, "\0"_sv));
|
||||
|
||||
if(depth < 0)
|
||||
{
|
||||
|
@ -3124,6 +3123,7 @@ ircd::m::dbs::room_state_space_key(const mutable_buffer &out_,
|
|||
return { data(out_), data(out) };
|
||||
}
|
||||
|
||||
consume(out, copy(out, "\0"_sv));
|
||||
consume(out, copy(out, byte_view<string_view>(depth)));
|
||||
|
||||
if(!event_idx)
|
||||
|
|
|
@ -2657,23 +2657,7 @@ bool
|
|||
ircd::m::room::state::space::for_each(const closure &closure)
|
||||
const
|
||||
{
|
||||
auto it
|
||||
{
|
||||
dbs::room_state_space.begin(room.room_id)
|
||||
};
|
||||
|
||||
for(; it; ++it)
|
||||
{
|
||||
const auto &key
|
||||
{
|
||||
dbs::room_state_space_key(it->first)
|
||||
};
|
||||
|
||||
if(!closure(std::get<0>(key), std::get<1>(key), std::get<2>(key), std::get<3>(key)))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return for_each(string_view{}, string_view{}, -1L, closure);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -2703,7 +2687,7 @@ const
|
|||
char buf[dbs::ROOM_STATE_SPACE_KEY_MAX_SIZE];
|
||||
const string_view &key
|
||||
{
|
||||
dbs::room_state_space_key(buf, room.room_id, type, state_key, depth)
|
||||
dbs::room_state_space_key(buf, room.room_id, type, state_key, depth, -1UL)
|
||||
};
|
||||
|
||||
auto it
|
||||
|
|
Loading…
Reference in a new issue