aboutsummaryrefslogtreecommitdiffstats
path: root/src/federation
diff options
context:
space:
mode:
Diffstat (limited to 'src/federation')
-rw-r--r--src/federation/vote.rs137
1 files changed, 0 insertions, 137 deletions
diff --git a/src/federation/vote.rs b/src/federation/vote.rs
index baf8dd0..0bad500 100644
--- a/src/federation/vote.rs
+++ b/src/federation/vote.rs
@@ -55,8 +55,6 @@ pub(crate) struct Rules {
/// How long it holds an event before it holds it for a while: the voters' rule, and how
/// long a new proposal holds back a checkpoint.
pub(crate) held_for: Duration,
- /// Voting `false` on a checkpoint proposed beside one it backs.
- pub(crate) nay_beside: bool,
/// How long its store holds its checkpoint, or runs, before it backs or proposes a
/// later one.
pub(crate) back_after: Duration,
@@ -382,9 +380,6 @@ pub(crate) fn decide(seen: &Seen<'_>, rules: &Rules, record: &Record) -> Vec<Act
});
}
}
- if rules.nay_beside {
- acts.extend(beside(&current, &all, &acts, record, &nays));
- }
if !backed && let Some(version) = checkpoint(seen, rules, &current, &all) {
let hash = Id::of(&version.bytes());
if record
@@ -397,64 +392,6 @@ pub(crate) fn decide(seen: &Seen<'_>, rules: &Rules, record: &Record) -> Vec<Act
acts
}
-/// The votes `false` a node casts beside what it backs: where its party backs a proposal on
-/// `current` that can still pass, by its `record` or by `acts`, on every other proposal
-/// that only moves to a checkpoint and can still pass, but where it votes already.
-fn beside(
- current: &Version,
- all: &[Proposed],
- acts: &[Act],
- record: &Record,
- nays: &[Vec<u8>],
-) -> Vec<Act> {
- let voting: BTreeSet<Id> = acts
- .iter()
- .filter_map(|act| match act {
- Act::Vote { proposal, .. } => Some(*proposal),
- Act::Propose(_) => None,
- })
- .collect();
- let backs: BTreeSet<Id> = record
- .backs(&current.hash)
- .into_iter()
- .chain(acts.iter().filter_map(|act| match act {
- Act::Vote {
- proposal,
- yes: true,
- ..
- } => Some(*proposal),
- _ => None,
- }))
- .collect();
- let backing = all
- .iter()
- .any(|proposed| backs.contains(&proposed.hash) && alive(current, proposed));
- if !backing {
- return Vec::new();
- }
- all.iter()
- .filter(|proposed| {
- !backs.contains(&proposed.hash)
- && !voting.contains(&proposed.hash)
- && alive(current, proposed)
- && proposed
- .version
- .as_ref()
- .is_some_and(|version| version.only_moves_on(current))
- })
- .filter(|proposed| {
- record
- .may_vote(current, proposed.hash, &proposed.json, false, nays)
- .is_ok()
- })
- .map(|proposed| Act::Vote {
- proposal: proposed.hash,
- yes: false,
- nays: Vec::new(),
- })
- .collect()
-}
-
/// A vote by hand, cast through the node that votes for its party, which keeps its
/// party's one record: `yes` on the proposal of hash `proposal` on the current version, by
/// the record, and with a `true` by the voters' rule; or why not.
@@ -1180,78 +1117,4 @@ mod tests {
let record = super::tests::record(&apart, "tv");
assert!(decide(&seen(&apart, &held), &rules, &record).is_empty());
}
-
- /// Two checkpoints proposed at once: a node backing one votes `false` on the other by
- /// its rule, and on nothing else; without the rule, on nothing.
- #[test]
- fn a_node_votes_false_on_a_checkpoint_beside_the_one_it_backs() {
- let (tv, lass, _, first, mut store) = three();
- let root = store.id();
- let on = first.hash();
- let here = taken(
- &mut store,
- tv.write(&[root], "home/tv/a", harness::str("1")),
- );
- let there = taken(
- &mut store,
- lass.write(&[root], "home/lass/b", harness::str("1")),
- );
- let (mut one, mut two) = (first.after(on), first.after(on));
- one.checkpoint = Some(vec![here]);
- two.checkpoint = Some(vec![there]);
- let mut other = first.after(on);
- other.rules.push(("names/x".to_owned(), harness::str("tv")));
- let proposing = tv.propose(&[here], &one.json());
- let mut record = record(&store, "tv");
- record.signed(&proposing);
- let proposal = taken(&mut store, proposing);
- let by_lass = [
- taken(&mut store, lass.propose(&[there], &two.json())),
- taken(&mut store, lass.propose(&[root], &other.json())),
- ];
- // lass's, held since its proposals came, after tv proposed.
- let long = |id: &Id| {
- Some(if *id == there || by_lass.contains(id) {
- Duration::from_secs(60)
- } else {
- Duration::from_secs(3600)
- })
- };
- let rules = Rules {
- nay_beside: true,
- ..Rules::default()
- };
- // Backing its own, this round: `false` on the other checkpoint, not on the version
- // that changes more.
- let acts = decide(&seen(&store, &long), &rules, &record);
- assert_eq!(acts.len(), 2, "{acts:?}");
- assert!(acts.contains(&Act::Vote {
- proposal: one.hash(),
- yes: true,
- nays: Vec::new()
- }));
- assert!(acts.contains(&Act::Vote {
- proposal: two.hash(),
- yes: false,
- nays: Vec::new()
- }));
- let quiet = Rules::default();
- assert_eq!(decide(&seen(&store, &long), &quiet, &record).len(), 1);
- // Its `true` recorded and taken: `false` on the other, once.
- let yes = tv.vote(&[proposal], on, one.hash(), true);
- record.cast(store.state().current(), &yes, Vec::new());
- taken(&mut store, yes);
- let acts = decide(&seen(&store, &long), &rules, &record);
- assert_eq!(
- acts,
- vec![Act::Vote {
- proposal: two.hash(),
- yes: false,
- nays: Vec::new()
- }]
- );
- let no = tv.vote(&[proposal], on, two.hash(), false);
- record.cast(store.state().current(), &no, Vec::new());
- assert!(decide(&seen(&store, &long), &rules, &record).is_empty());
- }
}