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

ircd:Ⓜ️:dbs: Add a room_events_key generator which doesn't require event_id.

This commit is contained in:
Jason Volk 2018-02-13 14:21:57 -08:00
parent 032156a18e
commit ad56d381a5
2 changed files with 15 additions and 0 deletions

View file

@ -29,6 +29,7 @@ namespace ircd::m::dbs
// Lowlevel util
string_view room_events_key(const mutable_buffer &out, const id::room &, const uint64_t &depth, const id::event &);
string_view room_events_key(const mutable_buffer &out, const id::room &, const uint64_t &depth);
std::tuple<uint64_t, string_view> room_events_key(const string_view &amalgam);
// Get the state root for an event (with as much information as you have)

View file

@ -381,6 +381,20 @@ ircd::m::dbs::desc::events__room_events__cmp
}
};
//TODO: optimize
//TODO: Needs The Gramslam
ircd::string_view
ircd::m::dbs::room_events_key(const mutable_buffer &out,
const id::room &room_id,
const uint64_t &depth)
{
size_t len{0};
len = strlcpy(out, room_id);
len = strlcat(out, ":::");
len = strlcat(out, lex_cast(depth));
return { data(out), len };
}
//TODO: optimize
//TODO: Needs The Gramslam
ircd::string_view