blob: 1cb14523a2545cc5229bf51365980c8fc5b436b2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
//! Banned nodes (`_continuum/banned/<node ID>`, `{"by", "at", "reason"}`), written by a
//! user who may write there, as any protocol data: a node refuses a banned node's
//! handshake, so it neither syncs with it nor counts it a member (`swarm::peer`), and
//! with the swarm's policy every node refuses the changes a banned node commits
//! (`access::rules`, judged as the ban stood when they were made), and the tokens it
//! issued (`access::token`). Deleting the entry lifts the ban.
use crate::document::meta;
use crate::document::view::{self, Read};
/// Where `node`'s ban is.
pub(crate) fn path(node: &str) -> Vec<String> {
meta::path(&[meta::BANNED, node])
}
/// Whether `doc` bans `node`.
pub(crate) fn banned(doc: &(impl Read + ?Sized), node: &str) -> bool {
view::read_plain(doc, &path(node)).ok().flatten().is_some()
}
|