aboutsummaryrefslogtreecommitdiffstats
path: root/src/federation
diff options
context:
space:
mode:
Diffstat (limited to 'src/federation')
-rw-r--r--src/federation/held.rs18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/federation/held.rs b/src/federation/held.rs
index dc0db6f..fec21ab 100644
--- a/src/federation/held.rs
+++ b/src/federation/held.rs
@@ -111,6 +111,8 @@ pub(crate) struct Holding {
members: RwLock<Option<BTreeSet<(String, String)>>>,
/// What it votes for its party with, if it votes by itself.
voter: Option<Voter>,
+ /// Whether a set of events carries the store (`carrying`), from the node's start on.
+ of_a_set: bool,
// A std mutex: never held while waiting for the document.
inner: Mutex<Inner>,
}
@@ -261,6 +263,7 @@ impl Holding {
near: Vec::new(),
members: RwLock::default(),
voter: None,
+ of_a_set: false,
inner: Mutex::new(Inner {
kept,
..Inner::default()
@@ -1017,7 +1020,8 @@ impl Holding {
/// Itself, its store carried by `set`: the store's own document, read from no
/// other (`store::set`).
- pub(crate) fn carrying(self, set: Set<Federation>) -> Self {
+ pub(crate) fn carrying(mut self, set: Set<Federation>) -> Self {
+ self.of_a_set = true;
{
let mut inner = self.inner.lock_or_recover();
inner.store = Some(Carried::Set(Box::new(set)));
@@ -1029,12 +1033,18 @@ impl Holding {
/// The kind of the document that carries the store: a set of events, or the
/// document the node holds, which the store is read from.
pub(crate) fn kind(&self) -> &'static str {
- match self.inner.lock_or_recover().store {
- Some(Carried::Set(_)) => super::store::set::KIND,
- _ => crate::document::KIND,
+ if self.of_a_set {
+ super::store::set::KIND
+ } else {
+ crate::document::KIND
}
}
+ /// Whether a set of events carries the store.
+ pub(crate) fn of_a_set(&self) -> bool {
+ self.of_a_set
+ }
+
/// What `f` makes of the set of events carrying the store, where one does.
pub(crate) fn with_set<T>(&self, f: impl FnOnce(&Set<Federation>) -> T) -> Option<T> {
match &self.inner.lock_or_recover().store {