Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
cob: Don't overwrite nodes during traversal
Alexis Sellier committed 3 years ago
commit 3e9c3d2679d8f336ed5cbdd89647761403222bfe
parent 730eaa00caa14aa987a665585ccfef63d07a2363
2 files changed +8 -2
modified radicle-cob/src/change_graph.rs
@@ -130,8 +130,9 @@ impl GraphBuilder {
        let resource_commit = *change.resource();
        let commit_id = commit.id;

-
        self.graph.node(commit_id, change);
-

+
        if !self.graph.contains(&commit_id) {
+
            self.graph.node(commit_id, change);
+
        }
        commit.parents.into_iter().filter_map(move |parent| {
            if parent.id != resource_commit && !self.graph.has_dependency(&commit_id, &parent.id) {
                Some((parent, commit_id))
modified radicle-dag/src/lib.rs
@@ -103,6 +103,11 @@ impl<K: Eq + Copy + Hash, V> Dag<K, V> {
        }
    }

+
    /// Check if the graph contains a node.
+
    pub fn contains(&self, key: &K) -> bool {
+
        self.graph.contains_key(key)
+
    }
+

    /// Get a node.
    pub fn get(&self, key: &K) -> Option<&Node<K, V>> {
        self.graph.get(key)