aboutsummaryrefslogtreecommitdiffstats
path: root/src/remake
diff options
context:
space:
mode:
Diffstat (limited to 'src/remake')
-rw-r--r--src/remake/catchup.rs1
-rw-r--r--src/remake/records.rs1
-rw-r--r--src/remake/snapshot.rs6
-rw-r--r--src/remake/switch.rs3
4 files changed, 10 insertions, 1 deletions
diff --git a/src/remake/catchup.rs b/src/remake/catchup.rs
index 9830c33..4df5c90 100644
--- a/src/remake/catchup.rs
+++ b/src/remake/catchup.rs
@@ -718,6 +718,7 @@ mod tests {
&mut old,
&SnapshotParams {
remake_id: "c-1",
+ coordinator: "a",
previous: Epoch::GENESIS,
base_heads: &base,
policy,
diff --git a/src/remake/records.rs b/src/remake/records.rs
index 21b383c..21cf0ae 100644
--- a/src/remake/records.rs
+++ b/src/remake/records.rs
@@ -306,6 +306,7 @@ impl Record {
) -> Option<SnapshotRequest> {
Some(SnapshotRequest {
remake_id: id.to_owned(),
+ coordinator: self.proposal.coordinator.clone(),
previous: self.proposal.from_epoch.to_epoch()?,
base_heads: base,
policy: serde_json::to_value(&self.proposal.policy).ok()?,
diff --git a/src/remake/snapshot.rs b/src/remake/snapshot.rs
index 220989e..7938b53 100644
--- a/src/remake/snapshot.rs
+++ b/src/remake/snapshot.rs
@@ -36,6 +36,8 @@ use crate::document::store::{self, StoreError};
pub(crate) struct SnapshotParams<'a> {
/// ID of the committed remake; seeds the snapshot actor.
pub(crate) remake_id: &'a str,
+ /// The node coordinating it: the one that carries its record into the new epoch.
+ pub(crate) coordinator: &'a str,
/// The epoch being compacted. The snapshot starts generation `previous + 1`.
pub(crate) previous: Epoch,
/// Heads of the base. Every node must hold all of these changes.
@@ -84,6 +86,7 @@ pub(crate) enum SnapshotError {
#[derive(Clone, Debug)]
pub(crate) struct SnapshotRequest {
pub(crate) remake_id: String,
+ pub(crate) coordinator: String,
pub(crate) previous: Epoch,
pub(crate) base_heads: Vec<ChangeHash>,
pub(crate) policy: JsonValue,
@@ -97,6 +100,7 @@ impl SnapshotRequest {
pub(crate) fn params(&self) -> SnapshotParams<'_> {
SnapshotParams {
remake_id: &self.remake_id,
+ coordinator: &self.coordinator,
previous: self.previous,
base_heads: &self.base_heads,
policy: &self.policy,
@@ -311,6 +315,7 @@ pub(crate) fn build(
let metadata = canonical(json!({
"generation": generation,
"remakeId": params.remake_id,
+ "coordinator": params.coordinator,
"previous": {
"generation": params.previous.generation,
"id": params.previous.id_hex(),
@@ -391,6 +396,7 @@ mod tests {
fn params<'a>(heads: &'a [ChangeHash], policy: &'a JsonValue) -> SnapshotParams<'a> {
SnapshotParams {
remake_id: "c-1",
+ coordinator: "a",
previous: Epoch::GENESIS,
base_heads: heads,
policy,
diff --git a/src/remake/switch.rs b/src/remake/switch.rs
index 34c492f..bd40d72 100644
--- a/src/remake/switch.rs
+++ b/src/remake/switch.rs
@@ -200,7 +200,8 @@ async fn switch<H: Host>(
// Only the coordinator carries the record into the new epoch: one writer, so the
// nodes don't all write the same path concurrently right after switching (a merge
// conflict, plus one change per node to sync). The epoch metadata in the snapshot
- // keeps the essentials on every node anyway.
+ // keeps the essentials on every node anyway, and names the coordinator: the rules
+ // take the record from it only (`access::rules`).
let carry_record = record.proposal.coordinator == host.node_id();
let record_path = records::record_path(id, "");