0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-29 10:12:39 +01:00

ircd:Ⓜ️:dbs: Add event_bad column for blacklisting.

This commit is contained in:
Jason Volk 2018-05-04 15:02:32 -07:00
parent 09a0b345c8
commit 66a4d52a93
2 changed files with 65 additions and 0 deletions

View file

@ -27,6 +27,7 @@ namespace ircd::m::dbs
// Event metadata columns // Event metadata columns
extern db::column event_idx; // event_id => event_idx extern db::column event_idx; // event_id => event_idx
extern db::column event_bad; // event_id => event_idx
extern db::index room_events; // room_id | depth, event_idx => state_root extern db::index room_events; // room_id | depth, event_idx => state_root
extern db::index room_joined; // room_id | origin, member => event_idx extern db::index room_joined; // room_id | origin, member => event_idx
extern db::index room_state; // room_id | type, state_key => event_idx extern db::index room_state; // room_id | type, state_key => event_idx
@ -107,6 +108,9 @@ namespace ircd::m::dbs::desc
// events index // events index
extern const database::descriptor events__event_idx; extern const database::descriptor events__event_idx;
// events blacklist
extern const database::descriptor events__event_bad;
// room events sequence // room events sequence
extern const db::prefix_transform events__room_events__pfx; extern const db::prefix_transform events__room_events__pfx;
extern const db::comparator events__room_events__cmp; extern const db::comparator events__room_events__cmp;

View file

@ -26,6 +26,11 @@ decltype(ircd::m::dbs::event_idx)
ircd::m::dbs::event_idx ircd::m::dbs::event_idx
{}; {};
/// Linkage for a reference to the event_bad column.
decltype(ircd::m::dbs::event_bad)
ircd::m::dbs::event_bad
{};
/// Linkage for a reference to the state_node column. /// Linkage for a reference to the state_node column.
decltype(ircd::m::dbs::state_node) decltype(ircd::m::dbs::state_node)
ircd::m::dbs::state_node ircd::m::dbs::state_node
@ -71,6 +76,7 @@ ircd::m::dbs::init::init(std::string dbopts)
// Cache the columns for the metadata // Cache the columns for the metadata
event_idx = db::column{*events, desc::events__event_idx.name}; event_idx = db::column{*events, desc::events__event_idx.name};
event_bad = db::column{*events, desc::events__event_bad.name};
state_node = db::column{*events, desc::events__state_node.name}; state_node = db::column{*events, desc::events__state_node.name};
room_events = db::index{*events, desc::events__room_events.name}; room_events = db::index{*events, desc::events__room_events.name};
room_joined = db::index{*events, desc::events__room_joined.name}; room_joined = db::index{*events, desc::events__room_joined.name};
@ -494,6 +500,57 @@ ircd::m::dbs::desc::events__event_idx
false, false,
}; };
const ircd::database::descriptor
ircd::m::dbs::desc::events__event_bad
{
// name
"_event_bad",
// explanation
R"(### developer note:
The key is an event_id. The mere existence of the key indicates we do not
have this event; it will not be a key found in the event_idx and will not
have its own idx number and we know nothing else about this event.
However the value is an optional index number of *another* event which is
recommended to be used when this missing event was essential. For example,
if other servers accept the bad event and then continue a room DAG it is
essential we know the last good prev reference to have an unbroken trace.
Such a prev reference will be recorded in this value for said use.
If this column has no value or a zero value it is being used to blacklist
an event_id for some other reason.
)",
// typing (key, value)
{
typeid(string_view), typeid(uint64_t)
},
// options
{},
// comparator
{},
// prefix transform
{},
// cache size
16_MiB, //TODO: conf
// cache size for compressed assets
8_MiB, //TODO: conf
// bloom filter bits
16,
// expect queries hit
false,
};
/// Prefix transform for the events__room_events. The prefix here is a room_id /// Prefix transform for the events__room_events. The prefix here is a room_id
/// and the suffix is the depth+event_id concatenation. /// and the suffix is the depth+event_id concatenation.
/// for efficient sequences /// for efficient sequences
@ -1712,6 +1769,10 @@ ircd::m::dbs::desc::events
// Mapping of event_id to index number. // Mapping of event_id to index number.
events__event_idx, events__event_idx,
// event_id => uint64_t
// Mapping of faulty event_id to possible alternative event_idx.
events__event_bad,
// (room_id, (depth, event_idx)) => (state_root) // (room_id, (depth, event_idx)) => (state_root)
// Sequence of all events for a room, ever. // Sequence of all events for a room, ever.
events__room_events, events__room_events,