Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
cob: Don't require full `Entry` for update
cloudhead committed 2 years ago
commit 66950744794ae7dd4d0840c3bc38e1624143abcc
parent c903a958e7600f4758997d82a0e2d5017a82df57
6 files changed +16 -20
modified radicle-cob/src/lib.rs
@@ -77,7 +77,7 @@ mod change_graph;
mod trailers;

pub mod change;
-
pub use change::store::{Contents, Embed, Manifest, Version};
+
pub use change::store::{Contents, Embed, EntryId, Manifest, Version};
pub use change::Entry;

pub mod history;
modified radicle-cob/src/object/collaboration/create.rs
@@ -71,7 +71,7 @@ where
    let object_id = init_change.id().into();

    storage
-
        .update(identifier, &type_name, &object_id, &init_change)
+
        .update(identifier, &type_name, &object_id, &init_change.id)
        .map_err(|err| error::Create::Refs { err: Box::new(err) })?;

    let history = History::new_from_root(init_change);
modified radicle-cob/src/object/collaboration/update.rs
@@ -96,7 +96,7 @@ where
    )?;

    storage
-
        .update(identifier, typename, &object_id, &change)
+
        .update(identifier, typename, &object_id, &change.id)
        .map_err(|err| error::Update::Refs { err: Box::new(err) })?;

    let parents = change.parents.to_vec();
modified radicle-cob/src/object/storage.rs
@@ -5,7 +5,7 @@ use std::{collections::BTreeMap, error::Error};
use git_ext::ref_format::RefString;
use git_ext::Oid;

-
use crate::change::Entry;
+
use crate::change::EntryId;
use crate::{ObjectId, TypeName};

/// The [`Reference`]s that refer to the commits that make up a
@@ -78,7 +78,7 @@ pub trait Storage {
        identifier: &Self::Identifier,
        typename: &TypeName,
        object_id: &ObjectId,
-
        change: &Entry,
+
        entry: &EntryId,
    ) -> Result<(), Self::UpdateError>;

    /// Remove a ref to a particular collaborative object
modified radicle-cob/src/test/storage.rs
@@ -154,7 +154,7 @@ impl object::Storage for Storage {
        identifier: &Self::Identifier,
        typename: &crate::TypeName,
        object_id: &ObjectId,
-
        change: &change::Entry,
+
        entry: &change::EntryId,
    ) -> Result<(), Self::UpdateError> {
        let name = format!(
            "refs/rad/{}/cobs/{}/{}",
@@ -162,8 +162,8 @@ impl object::Storage for Storage {
            typename,
            object_id
        );
-
        let id = *change.id();
-
        self.raw.reference(&name, id.into(), true, "new change")?;
+
        self.raw
+
            .reference(&name, (*entry).into(), true, "new change")?;
        Ok(())
    }

modified radicle/src/storage/git/cob.rs
@@ -139,17 +139,15 @@ impl cob::object::Storage for Repository {
        identifier: &Self::Identifier,
        typename: &cob::TypeName,
        object_id: &cob::ObjectId,
-
        change: &cob::Entry,
+
        entry: &cob::EntryId,
    ) -> Result<(), Self::UpdateError> {
        self.backend.reference(
            git::refs::storage::cob(identifier, typename, object_id).as_str(),
-
            (*change.id()).into(),
+
            (*entry).into(),
            true,
            &format!(
-
                "Updating collaborative object '{}/{}' with new change {}",
-
                typename,
-
                object_id,
-
                change.id()
+
                "Updating collaborative object '{}/{}' with new entry {}",
+
                typename, object_id, entry,
            ),
        )?;

@@ -387,17 +385,15 @@ impl<'a> cob::object::Storage for DraftStore<'a> {
        identifier: &Self::Identifier,
        typename: &cob::TypeName,
        object_id: &cob::ObjectId,
-
        change: &cob::Entry,
+
        entry: &cob::history::EntryId,
    ) -> Result<(), Self::UpdateError> {
        self.repo.backend.reference(
            git::refs::storage::draft::cob(identifier, typename, object_id).as_str(),
-
            (*change.id()).into(),
+
            (*entry).into(),
            true,
            &format!(
-
                "Updating draft collaborative object '{}/{}' with new change {}",
-
                typename,
-
                object_id,
-
                change.id()
+
                "Updating draft collaborative object '{}/{}' with new entry {}",
+
                typename, object_id, entry,
            ),
        )?;