2019-02-08 11:17:14 +01:00
|
|
|
// Matrix Construct
|
|
|
|
//
|
|
|
|
// Copyright (C) Matrix Construct Developers, Authors & Contributors
|
|
|
|
// Copyright (C) 2016-2018 Jason Volk <jason@zemos.net>
|
|
|
|
//
|
|
|
|
// Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
// purpose with or without fee is hereby granted, provided that the above
|
|
|
|
// copyright notice and this permission notice is present in all copies. The
|
|
|
|
// full license for this software is available in the LICENSE file.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
#define HAVE_IRCD_M_EVENT_AUTH_H
|
|
|
|
|
2019-02-13 02:50:44 +01:00
|
|
|
struct ircd::m::event::auth
|
2019-02-08 11:17:14 +01:00
|
|
|
{
|
2019-02-13 02:50:44 +01:00
|
|
|
struct refs;
|
|
|
|
struct chain;
|
|
|
|
|
|
|
|
static bool is_power_event(const event &);
|
2019-02-13 03:02:51 +01:00
|
|
|
static string_view failed(const event &, const vector_view<const event *> &auth_events);
|
2019-02-13 02:50:44 +01:00
|
|
|
static string_view failed(const event &);
|
|
|
|
static bool check(std::nothrow_t, const event &);
|
|
|
|
static void check(const event &);
|
|
|
|
};
|
2019-02-08 11:50:10 +01:00
|
|
|
|
2019-02-12 20:03:01 +01:00
|
|
|
/// 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.
|
2019-02-13 02:50:44 +01:00
|
|
|
struct ircd::m::event::auth::refs
|
2019-02-08 11:50:10 +01:00
|
|
|
{
|
|
|
|
event::idx idx;
|
|
|
|
|
|
|
|
public:
|
2019-02-08 16:07:19 +01:00
|
|
|
using closure_bool = event::closure_idx_bool;
|
|
|
|
|
|
|
|
bool for_each(const string_view &type, const closure_bool &) const;
|
2019-02-08 11:50:10 +01:00
|
|
|
bool for_each(const closure_bool &) const;
|
2019-02-08 16:07:19 +01:00
|
|
|
|
|
|
|
bool has(const string_view &type) const noexcept;
|
2019-02-08 11:50:10 +01:00
|
|
|
bool has(const event::idx &) const noexcept;
|
2019-02-08 16:07:19 +01:00
|
|
|
|
|
|
|
size_t count(const string_view &type) const noexcept;
|
2019-02-08 11:50:10 +01:00
|
|
|
size_t count() const noexcept;
|
|
|
|
|
2019-02-13 02:50:44 +01:00
|
|
|
refs(const event::idx &idx)
|
2019-02-08 16:07:19 +01:00
|
|
|
:idx{idx}
|
2019-02-15 01:48:45 +01:00
|
|
|
{}
|
2019-02-08 11:50:10 +01:00
|
|
|
};
|
2019-02-13 02:50:44 +01:00
|
|
|
|
|
|
|
struct ircd::m::event::auth::chain
|
|
|
|
{
|
2019-02-17 00:03:49 +01:00
|
|
|
using closure_bool = event::closure_idx_bool;
|
|
|
|
using closure = event::closure_idx;
|
2019-02-15 01:48:45 +01:00
|
|
|
|
2019-02-13 02:50:44 +01:00
|
|
|
event::idx idx;
|
|
|
|
|
2019-02-15 01:48:45 +01:00
|
|
|
static bool for_each(const auth::chain &, const closure_bool &);
|
2019-02-13 02:50:44 +01:00
|
|
|
|
2019-02-15 01:48:45 +01:00
|
|
|
public:
|
2019-02-13 02:50:44 +01:00
|
|
|
bool for_each(const closure_bool &) const;
|
2019-02-17 00:03:49 +01:00
|
|
|
bool for_each(const closure &) const;
|
|
|
|
|
2019-02-13 02:50:44 +01:00
|
|
|
bool has(const string_view &type) const noexcept;
|
|
|
|
size_t depth() const noexcept;
|
|
|
|
|
|
|
|
chain(const event::idx &idx)
|
|
|
|
:idx{idx}
|
2019-02-15 01:48:45 +01:00
|
|
|
{}
|
2019-02-13 02:50:44 +01:00
|
|
|
};
|