mirror of
https://github.com/matrix-construct/construct
synced 2025-02-20 02:30:07 +01:00
ircd:Ⓜ️:event::auth: Add comments; remove cruft.
This commit is contained in:
parent
4d95daf8e3
commit
8a81a6d24e
4 changed files with 5 additions and 126 deletions
|
@ -16,6 +16,11 @@ namespace ircd::m
|
|||
bool is_power_event(const event &);
|
||||
}
|
||||
|
||||
/// Interface to the references made by other power events to this power
|
||||
/// event in the `auth_events`. This interface only deals with power events,
|
||||
/// it doesn't care if a non-power event referenced a power event. This does
|
||||
/// not contain the auth-chain or state resolution algorithm here, those are
|
||||
/// later constructed out of this data.
|
||||
struct ircd::m::event::auth
|
||||
{
|
||||
struct chain;
|
||||
|
@ -42,18 +47,3 @@ struct ircd::m::event::auth
|
|||
|
||||
static void rebuild();
|
||||
};
|
||||
|
||||
struct ircd::m::event::auth::chain
|
||||
{
|
||||
event::auth auth;
|
||||
|
||||
public:
|
||||
using closure = std::function<event::idx (const event::idx &)>;
|
||||
|
||||
bool for_each(const string_view &type, const closure &) const;
|
||||
bool for_each(const closure &) const;
|
||||
|
||||
chain(const event::idx &idx)
|
||||
:auth{idx}
|
||||
{}
|
||||
};
|
||||
|
|
|
@ -1212,39 +1212,6 @@ ircd::m::is_power_event(const m::event &event)
|
|||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// event::auth::chain
|
||||
//
|
||||
|
||||
bool
|
||||
ircd::m::event::auth::chain::for_each(const closure &closure)
|
||||
const
|
||||
{
|
||||
return for_each(string_view{}, closure);
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::m::event::auth::chain::for_each(const string_view &type,
|
||||
const closure &c)
|
||||
const
|
||||
{
|
||||
using prototype = bool (chain::*)(const string_view &, const closure &) const;
|
||||
|
||||
static mods::import<prototype> call
|
||||
{
|
||||
"m_event", "ircd::m::event::auth::chain::for_each"
|
||||
};
|
||||
|
||||
//TODO: make this work (no pun intended)
|
||||
//return call(this, type, c);
|
||||
|
||||
if(!call) call.reload();
|
||||
const void *const v(call.get());
|
||||
const prototype mfp(*reinterpret_cast<const prototype *>(&v));
|
||||
const chain *const volatile that(this);
|
||||
return std::invoke(mfp, that, type, c);
|
||||
}
|
||||
|
||||
//
|
||||
// event::auth
|
||||
//
|
||||
|
|
|
@ -6007,50 +6007,6 @@ console_cmd__event__auth(opt &out, const string_view &line)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
console_cmd__event__auth__chain(opt &out, const string_view &line)
|
||||
{
|
||||
const params param{line, " ",
|
||||
{
|
||||
"event_id", "type"
|
||||
}};
|
||||
|
||||
const m::event::id &event_id
|
||||
{
|
||||
param.at("event_id")
|
||||
};
|
||||
|
||||
const string_view type
|
||||
{
|
||||
param.at("type", ""_sv)
|
||||
};
|
||||
|
||||
const m::event::auth::chain auth
|
||||
{
|
||||
index(event_id)
|
||||
};
|
||||
|
||||
auth.for_each(type, [&out]
|
||||
(const m::event::idx &idx)
|
||||
{
|
||||
const m::event::fetch event
|
||||
{
|
||||
idx, std::nothrow
|
||||
};
|
||||
|
||||
if(!event.valid)
|
||||
return true;
|
||||
|
||||
out << idx
|
||||
<< " " << pretty_oneline(event)
|
||||
<< std::endl;
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
console_cmd__event__auth__rebuild(opt &out, const string_view &line)
|
||||
{
|
||||
|
|
|
@ -624,40 +624,6 @@ ircd::m::event::refs::rebuild()
|
|||
txn();
|
||||
}
|
||||
|
||||
bool
|
||||
IRCD_MODULE_EXPORT
|
||||
ircd::m::event::auth::chain::for_each(const string_view &type,
|
||||
const event::auth::chain::closure &closure)
|
||||
const
|
||||
{
|
||||
event::idx next(0);
|
||||
event::auth auth(this->auth);
|
||||
uint64_t depth[2] {uint64_t(-1), 0}; do
|
||||
{
|
||||
auth.for_each(type, [&depth, &next]
|
||||
(const event::idx &event_idx)
|
||||
{
|
||||
if(!m::get(event_idx, "depth", depth[1]))
|
||||
return true;
|
||||
|
||||
if(depth[1] >= depth[0])
|
||||
return true;
|
||||
|
||||
depth[0] = depth[1];
|
||||
next = event_idx;
|
||||
return true;
|
||||
});
|
||||
|
||||
if(!closure(next))
|
||||
return false;
|
||||
|
||||
auth.idx = next;
|
||||
next = 0;
|
||||
}
|
||||
while(auth.idx);
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
IRCD_MODULE_EXPORT
|
||||
ircd::m::event::auth::rebuild()
|
||||
|
|
Loading…
Add table
Reference in a new issue