From fbc78c9c60a2182b18355a42c8d82e5f7b58a258 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Wed, 18 Apr 2018 15:09:13 -0700 Subject: [PATCH] ircd::m: Add head_idx(room) convenience to get one head event idx. --- include/ircd/m/room.h | 4 ++++ ircd/m/room.cc | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/include/ircd/m/room.h b/include/ircd/m/room.h index b1ee4c85c..82d2ed238 100644 --- a/include/ircd/m/room.h +++ b/include/ircd/m/room.h @@ -43,6 +43,10 @@ namespace ircd::m id::event::buf head(std::nothrow_t, const id::room &); id::event::buf head(const id::room &); + // [GET] Current Event idx (non-locking) (one only) + event::idx head_idx(std::nothrow_t, const id::room &); + event::idx head_idx(const id::room &); + // [GET] Current Event depth (non-locking) (one only) int64_t depth(std::nothrow_t, const id::room &); int64_t depth(const id::room &); diff --git a/ircd/m/room.cc b/ircd/m/room.cc index 570c40e1c..9d1e28e75 100644 --- a/ircd/m/room.cc +++ b/ircd/m/room.cc @@ -23,6 +23,19 @@ ircd::m::depth(std::nothrow_t, return std::get(top(std::nothrow, room_id)); } +ircd::m::event::idx +ircd::m::head_idx(const id::room &room_id) +{ + return std::get(top(room_id)); +} + +ircd::m::event::idx +ircd::m::head_idx(std::nothrow_t, + const id::room &room_id) +{ + return std::get(top(std::nothrow, room_id)); +} + ircd::m::event::id::buf ircd::m::head(const id::room &room_id) {