From 02bc9032e8ea44e93cbfc3d2c204d882d18d31c7 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Wed, 18 Apr 2018 15:04:46 -0700 Subject: [PATCH] ircd::m: Add event::idx to top() tuple. --- include/ircd/m/room.h | 4 ++-- ircd/m/room.cc | 20 ++++++++++++-------- ircd/m/vm.cc | 2 +- modules/client/rooms/rooms.cc | 2 +- modules/federation/make_join.cc | 2 +- modules/federation/make_leave.cc | 2 +- 6 files changed, 18 insertions(+), 14 deletions(-) diff --git a/include/ircd/m/room.h b/include/ircd/m/room.h index cca4aa0d9..b1ee4c85c 100644 --- a/include/ircd/m/room.h +++ b/include/ircd/m/room.h @@ -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 top(std::nothrow_t, const id::room &); - std::tuple top(const id::room &); + std::tuple top(std::nothrow_t, const id::room &); + std::tuple top(const id::room &); // [GET] Current Event ID (non-locking) (one only) id::event::buf head(std::nothrow_t, const id::room &); diff --git a/ircd/m/room.cc b/ircd/m/room.cc index 70abaef7a..570c40e1c 100644 --- a/ircd/m/room.cc +++ b/ircd/m/room.cc @@ -23,20 +23,20 @@ ircd::m::depth(std::nothrow_t, return std::get(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(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(top(std::nothrow, room_id)); } -std::tuple +std::tuple 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 +std::tuple 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 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 ret + { + event::id::buf{}, depth, event_idx + }; + event::fetch::event_id(event_idx, std::nothrow, [&ret] (const event::id &event_id) { diff --git a/ircd/m/vm.cc b/ircd/m/vm.cc index 523b40002..a2f8029e8 100644 --- a/ircd/m/vm.cc +++ b/ircd/m/vm.cc @@ -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 { diff --git a/modules/client/rooms/rooms.cc b/modules/client/rooms/rooms.cc index 0e5cbd421..2215a1a62 100644 --- a/modules/client/rooms/rooms.cc +++ b/modules/client/rooms/rooms.cc @@ -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_ diff --git a/modules/federation/make_join.cc b/modules/federation/make_join.cc index c10021a50..033ec6038 100644 --- a/modules/federation/make_join.cc +++ b/modules/federation/make_join.cc @@ -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 { diff --git a/modules/federation/make_leave.cc b/modules/federation/make_leave.cc index f77277c9e..9f7e5f43a 100644 --- a/modules/federation/make_leave.cc +++ b/modules/federation/make_leave.cc @@ -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 {