0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-26 07:23:53 +01:00

ircd:Ⓜ️ Add event::idx to top() tuple.

This commit is contained in:
Jason Volk 2018-04-18 15:04:46 -07:00
parent 7659ef3acc
commit 02bc9032e8
6 changed files with 18 additions and 14 deletions

View file

@ -36,8 +36,8 @@ namespace ircd::m
id::room::buf room_id(const string_view &id_or_alias);
// [GET] Current Event ID and depth suite (non-locking) (one only)
std::tuple<id::event::buf, int64_t> top(std::nothrow_t, const id::room &);
std::tuple<id::event::buf, int64_t> top(const id::room &);
std::tuple<id::event::buf, int64_t, event::idx> top(std::nothrow_t, const id::room &);
std::tuple<id::event::buf, int64_t, event::idx> top(const id::room &);
// [GET] Current Event ID (non-locking) (one only)
id::event::buf head(std::nothrow_t, const id::room &);

View file

@ -23,20 +23,20 @@ ircd::m::depth(std::nothrow_t,
return std::get<int64_t>(top(std::nothrow, room_id));
}
ircd::m::id::event::buf
ircd::m::event::id::buf
ircd::m::head(const id::room &room_id)
{
return std::get<event::id::buf>(top(room_id));
}
ircd::m::id::event::buf
ircd::m::event::id::buf
ircd::m::head(std::nothrow_t,
const id::room &room_id)
{
return std::get<event::id::buf>(top(std::nothrow, room_id));
}
std::tuple<ircd::m::id::event::buf, int64_t>
std::tuple<ircd::m::event::id::buf, int64_t, ircd::m::event::idx>
ircd::m::top(const id::room &room_id)
{
const auto ret
@ -53,7 +53,7 @@ ircd::m::top(const id::room &room_id)
return ret;
}
std::tuple<ircd::m::id::event::buf, int64_t>
std::tuple<ircd::m::event::id::buf, int64_t, ircd::m::event::idx>
ircd::m::top(std::nothrow_t,
const id::room &room_id)
{
@ -65,7 +65,7 @@ ircd::m::top(std::nothrow_t,
if(!it)
return
{
id::event::buf{}, -1
event::id::buf{}, -1, 0
};
const auto part
@ -73,10 +73,9 @@ ircd::m::top(std::nothrow_t,
dbs::room_events_key(it->first)
};
const int64_t &depth(std::get<0>(part));
std::tuple<id::event::buf, int64_t> ret
const int64_t &depth
{
id::event::buf{}, depth
int64_t(std::get<0>(part))
};
const event::idx &event_idx
@ -84,6 +83,11 @@ ircd::m::top(std::nothrow_t,
std::get<1>(part)
};
std::tuple<event::id::buf, int64_t, event::idx> ret
{
event::id::buf{}, depth, event_idx
};
event::fetch::event_id(event_idx, std::nothrow, [&ret]
(const event::id &event_id)
{

View file

@ -483,7 +483,7 @@ ircd::m::vm::_eval_pdu(eval &eval,
int64_t top;
id::event::buf head;
std::tie(top, head) = m::top(std::nothrow, room_id);
std::tie(head, top, std::ignore) = m::top(std::nothrow, room_id);
if(top < 0 && (opts.head_must_exist || opts.history))
throw error
{

View file

@ -203,7 +203,7 @@ commit__iov_iov(const room &room,
int64_t depth;
event::id::buf prev_event_id;
std::tie(prev_event_id, depth) = m::top(std::nothrow, room.room_id);
std::tie(prev_event_id, depth, std::ignore) = m::top(std::nothrow, room.room_id);
//TODO: X
const json::iov::set_if depth_

View file

@ -63,7 +63,7 @@ get__make_join(client &client,
int64_t depth;
m::id::event::buf prev_event_id;
std::tie(prev_event_id, depth) = m::top(room_id);
std::tie(prev_event_id, depth, std::ignore) = m::top(room_id);
const m::event::fetch evf
{

View file

@ -63,7 +63,7 @@ get__make_leave(client &client,
int64_t depth;
m::id::event::buf prev_event_id;
std::tie(prev_event_id, depth) = m::top(room_id);
std::tie(prev_event_id, depth, std::ignore) = m::top(room_id);
const m::event::fetch evf
{