Skip to content

Commit 18c972b

Browse files
committed
Small improvement to avoid copies and bugfix to protect the entire hash sequence.
1 parent fafba99 commit 18c972b

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

examples/transfer-collection.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ impl Node {
7474

7575
let tx = self.store.batch().await?;
7676
for (name, data) in named_blobs {
77-
let tmp_tag = tx.add_slice(data).await?;
77+
let tmp_tag = tx.add_bytes(data).await?;
7878
collection_items.insert(name, tmp_tag);
7979
}
8080

@@ -88,10 +88,9 @@ impl Node {
8888

8989
let collection = Collection::from_iter(collection_items);
9090

91-
let collection = collection.store(&self.store).await?;
92-
let hash = collection.hash().clone();
93-
self.store.tags().create(collection).await?;
94-
Ok(hash)
91+
let tt = collection.store(&self.store).await?;
92+
self.store.tags().create(*tt.hash_and_format()).await?;
93+
Ok(*tt.hash())
9594
}
9695

9796
/// retrive an entire collection from a given hash and provider

0 commit comments

Comments
 (0)