//! The protocol's own data in the document: everything under `_continuum`. The names //! of its parts, and the paths to them, are defined here only. //! //! * `members/`: the member registry (`swarm::members`). //! * `forgotten/`: forget records (`swarm::peer`). //! * `remakes/`: remake records (`remake::records`). //! * `votes/`: the votes register (`remake::records`). //! * `epochs/`: epoch metadata, written by snapshots (`remake::snapshot`). //! * `swarm`: the swarm ID, written once by the genesis node (`swarm::bootstrap`). //! * `neighbours`: the neighbours each member keeps, written by the genesis node, and //! changed by a protocol writer if need be (`swarm::topology::swarm_neighbours`). //! * `relays`: relays for the swarm's nodes, listed by an operator //! (`swarm::members::relays`). //! * `topology`, `dissemination`: how members' neighbours are chosen, and how a change //! reaches every member, written by the genesis node, and changed by a protocol //! writer if need be (`swarm::topology::swarm_ways`). //! * `users/`: the user registry: who the users are, and what each may do //! (`access::registry`). //! * `access/signed`: the paths whose writes are signed (`document::signatures`). //! * `access/policy`: whether every node judges received changes (`access::policy`). //! * `access/userSigned`: the paths whose values their users sign (`access::envelope`). //! * `banned/`: banned nodes (`access::bans`). //! * `logouts/`: when a user's tokens were last revoked (`access::registry`). //! * `sessions//`: a session of the user ended (logged out of), until //! when it would have lasted: its tokens aren't taken (`access::registry`). //! * `local//`: never stored, and never writable: what a node holds alone //! (its log filter, its configuration, its debug endpoints), named for capabilities //! (`api::access::needed`). /// The key every protocol path starts with. pub(crate) const ROOT: &str = "_continuum"; pub(crate) const MEMBERS: &str = "members"; pub(crate) const FORGOTTEN: &str = "forgotten"; pub(crate) const REMAKES: &str = "remakes"; pub(crate) const VOTES: &str = "votes"; pub(crate) const EPOCHS: &str = "epochs"; pub(crate) const SWARM: &str = "swarm"; pub(crate) const NEIGHBOURS: &str = "neighbours"; pub(crate) const RELAYS: &str = "relays"; pub(crate) const TOPOLOGY: &str = "topology"; pub(crate) const DISSEMINATION: &str = "dissemination"; pub(crate) const USERS: &str = "users"; pub(crate) const ACCESS: &str = "access"; pub(crate) const BANNED: &str = "banned"; pub(crate) const LOGOUTS: &str = "logouts"; pub(crate) const SESSIONS: &str = "sessions"; pub(crate) const LOCAL: &str = "local"; /// The store path `_continuum/`. pub(crate) fn path(parts: &[&str]) -> Vec { std::iter::once(ROOT) .chain(parts.iter().copied()) .map(str::to_owned) .collect() } /// Whether a store path is protocol data (under `_continuum`). pub(crate) fn is_protocol(path: &[String]) -> bool { path.first().is_some_and(|root| root == ROOT) } #[cfg(test)] mod tests { use super::*; #[test] fn paths_start_at_the_root() { assert_eq!(path(&[]), vec!["_continuum"]); assert_eq!(path(&[MEMBERS, "pk"]), vec!["_continuum", "members", "pk"]); assert!(is_protocol(&path(&[VOTES]))); assert!(!is_protocol(&["users".to_owned()])); assert!(!is_protocol(&[])); } }