diff options
Diffstat (limited to 'src/federation/held.rs')
| -rw-r--r-- | src/federation/held.rs | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/src/federation/held.rs b/src/federation/held.rs index fd43062..bb34407 100644 --- a/src/federation/held.rs +++ b/src/federation/held.rs @@ -1108,13 +1108,23 @@ impl Holding { } } - /// The members' entries as the node reads them of a document, each at - /// `_continuum/members/<node ID>`, where a set of events carries the store: the - /// document's place for them, which a set keeps apart. + /// What the node reads of its document at paths, where a set of events carries the + /// store: what a document holding a store has there. The members' entries, each at + /// `_continuum/members/<node ID>`, which a set keeps apart; the policy of a swarm + /// holding a store; and the swarm's ID, the store's. pub(crate) fn entries(&self) -> Option<crate::document::view::Tree> { use crate::document::view::{Tree, Write}; self.with_set(|set| { let mut tree = Tree::new(); + // Into a tree of maps alone: nothing is in the way of any of it. + let _ = tree.write_path( + &crate::access::policy::path(), + &events::policy(Federation::NAME), + ); + let _ = tree.write_path( + &meta::path(&[meta::SWARM]), + &serde_json::Value::String(set.store().id().to_string()), + ); for entry in set.entries() { if let Some(value) = entry.value() { let path = [ @@ -1122,7 +1132,6 @@ impl Holding { meta::MEMBERS.to_owned(), entry.node(), ]; - // Into a tree of maps alone: nothing is in the way. let _ = tree.write_path(&path, &serde_json::Value::Object(value)); } } @@ -2966,6 +2975,16 @@ mod tests { Some("tv".to_owned()) ); assert!(holding.member(&key.id(), Some("tv")) == Some(true)); + // And the rest a document holding a store has for the node to read: the + // policy, by which a node takes no token another issued, and the swarm's ID. + assert!(matches!( + crate::access::policy::of(&tree), + crate::access::policy::Policy::Store(_) + )); + assert_eq!( + crate::document::view::read_path(&tree, &meta::path(&[meta::SWARM])).unwrap(), + Some(serde_json::Value::String(Id::of(&root).to_string())) + ); assert!(Holding::default().entries().is_none()); } } |
