Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
cob: Return correct clock value for multi-ops
Alexis Sellier committed 3 years ago
commit 335fcbca89e4ffe0bd2c63690814429ab6ad9915
parent bdbf1111630116d487317e2a7cfac8123d4730fb
2 files changed +11 -2
modified radicle-cob/src/change_graph/evaluation.rs
@@ -9,6 +9,7 @@ use git_ext::Oid;
use petgraph::{visit::EdgeRef, EdgeDirection};

use crate::history::entry::{EntryId, EntryWithClock};
+
use crate::history::Clock;
use crate::{change::Change, history, pruning_fold};

/// # Panics
@@ -39,7 +40,12 @@ pub fn evaluate<'b>(
                let incoming = graph.edges_directed(c.idx, EdgeDirection::Incoming);
                let clock = incoming
                    .into_iter()
-
                    .map(|e| entries[&graph[e.source()].id.into()].clock())
+
                    .map(|e| {
+
                        let entry = &entries[&graph[e.source()].id.into()];
+
                        let clock = entry.clock();
+

+
                        clock + entry.contents().len() as Clock - 1
+
                    })
                    .max()
                    .map(|n| n + 1)
                    .unwrap_or_default();
modified radicle-cob/src/history.rs
@@ -82,7 +82,10 @@ impl History {
    pub fn clock(&self) -> Clock {
        self.graph
            .externals(petgraph::Direction::Outgoing)
-
            .map(|n| self.graph[n].clock)
+
            .map(|n| {
+
                let node = &self.graph[n];
+
                node.clock + node.entry.contents.len() as Clock - 1
+
            })
            .max()
            .unwrap_or_default()
    }