mirror of
https://github.com/matrix-construct/construct
synced 2024-06-30 07:48:22 +02:00
ircd:Ⓜ️ Additional room sounding tools; improve console cmd.
This commit is contained in:
parent
486ca09153
commit
e5563586cf
|
@ -29,8 +29,9 @@ namespace ircd::m
|
|||
bool for_each_depth_gap(const room &, const depth_range_closure &);
|
||||
bool rfor_each_depth_gap(const room &, const depth_range_closure &);
|
||||
|
||||
std::pair<int64_t, event::idx> first_missing(const room &);
|
||||
std::pair<int64_t, event::idx> surface(const room &); // First missing
|
||||
std::pair<int64_t, event::idx> sounding(const room &); // Last missing
|
||||
std::pair<int64_t, event::idx> twain(const room &);
|
||||
}
|
||||
|
||||
/// Interface to room messages
|
||||
|
|
17
ircd/m.cc
17
ircd/m.cc
|
@ -4779,6 +4779,17 @@ ircd::m::commit(const room &room,
|
|||
return eval.event_id;
|
||||
}
|
||||
|
||||
std::pair<int64_t, ircd::m::event::idx>
|
||||
ircd::m::twain(const room &r)
|
||||
{
|
||||
static mods::import<decltype(twain)> call
|
||||
{
|
||||
"m_room", "ircd::m::twain"
|
||||
};
|
||||
|
||||
return call(r);
|
||||
}
|
||||
|
||||
std::pair<int64_t, ircd::m::event::idx>
|
||||
ircd::m::sounding(const room &r)
|
||||
{
|
||||
|
@ -4791,11 +4802,11 @@ ircd::m::sounding(const room &r)
|
|||
}
|
||||
|
||||
std::pair<int64_t, ircd::m::event::idx>
|
||||
ircd::m::first_missing(const room &r)
|
||||
ircd::m::surface(const room &r)
|
||||
{
|
||||
static mods::import<decltype(first_missing)> call
|
||||
static mods::import<decltype(surface)> call
|
||||
{
|
||||
"m_room", "ircd::m::first_missing"
|
||||
"m_room", "ircd::m::surface"
|
||||
};
|
||||
|
||||
return call(r);
|
||||
|
|
|
@ -7388,14 +7388,31 @@ console_cmd__room__sounding(opt &out, const string_view &line)
|
|||
room_id
|
||||
};
|
||||
|
||||
const auto res
|
||||
const auto surface
|
||||
{
|
||||
m::surface(room)
|
||||
};
|
||||
|
||||
const auto sound
|
||||
{
|
||||
m::sounding(room)
|
||||
};
|
||||
|
||||
out << "depth: " << res.first << std::endl
|
||||
<< "event: " << res.second << " " << m::event_id(res.second) << std::endl
|
||||
;
|
||||
const auto twain
|
||||
{
|
||||
m::twain(room)
|
||||
};
|
||||
|
||||
out << "sounding: " << std::setw(8) << sound.first
|
||||
<< " " << m::event_id(sound.second) << " (" << sound.second << ")"
|
||||
<< std::endl;
|
||||
|
||||
out << "twain: " << std::setw(8) << twain.first
|
||||
<< std::endl;
|
||||
|
||||
out << "surface: " << std::setw(8) << surface.first
|
||||
<< " " << m::event_id(surface.second) << " (" << surface.second << ")"
|
||||
<< std::endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -477,6 +477,26 @@ ircd::m::room::head::for_each(const head &head,
|
|||
return true;
|
||||
}
|
||||
|
||||
std::pair<int64_t, ircd::m::event::idx>
|
||||
IRCD_MODULE_EXPORT
|
||||
ircd::m::twain(const room &room)
|
||||
{
|
||||
std::pair<int64_t, m::event::idx> ret
|
||||
{
|
||||
-1, 0
|
||||
};
|
||||
|
||||
rfor_each_depth_gap(room, [&ret]
|
||||
(const auto &range, const auto &event_idx)
|
||||
{
|
||||
ret.first = range.first - 1;
|
||||
ret.second = event_idx;
|
||||
return false;
|
||||
});
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::pair<int64_t, ircd::m::event::idx>
|
||||
IRCD_MODULE_EXPORT
|
||||
ircd::m::sounding(const room &room)
|
||||
|
@ -499,7 +519,7 @@ ircd::m::sounding(const room &room)
|
|||
|
||||
std::pair<int64_t, ircd::m::event::idx>
|
||||
IRCD_MODULE_EXPORT
|
||||
ircd::m::first_missing(const room &room)
|
||||
ircd::m::surface(const room &room)
|
||||
{
|
||||
std::pair<int64_t, m::event::idx> ret {0, 0};
|
||||
for_each_depth_gap(room, [&ret]
|
||||
|
@ -526,17 +546,24 @@ ircd::m::rfor_each_depth_gap(const room &room,
|
|||
if(!it)
|
||||
return true;
|
||||
|
||||
event::idx idx{0};
|
||||
for(depth_range range{0L, it.depth()}; it; --it)
|
||||
{
|
||||
range.first = it.depth();
|
||||
if(range.first == range.second)
|
||||
{
|
||||
idx = it.event_idx();
|
||||
continue;
|
||||
}
|
||||
|
||||
--range.second;
|
||||
if(range.first == range.second)
|
||||
{
|
||||
idx = it.event_idx();
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!closure({range.first+1, range.second+1}, it.event_idx()))
|
||||
if(!closure({range.first+1, range.second+1}, idx))
|
||||
return false;
|
||||
|
||||
range.second = range.first;
|
||||
|
|
Loading…
Reference in a new issue