--- Begin Message ---
Package: rust-ipfs-unixfs
Version: 0.2.0-2
Severity: important
X-debbugs-cc: d...@jones.dk
Control: block 1020418 by -1
Control: block 1020419 by -1
rust-ipfs-unixfs depends on version 0.11 of the multihash crate which was
superseeded nearly 2 years ago
and depends on an old version of the rustcrypto hash packages. Currently we
have two versions of some of
the rustcrypto packages in Debian while others are still on old versions.
Jonas recently requested updates of two more rustcrypto packages block-buffer
and block-padding, on the
one hand I think these should be updated, on the other hand I don't really want
to further increase the
number of packages for which we are carrying multiple versions in Debian.
So I started looking to see if I could update ipfs-unixfs to use the new
version of multihash, the good
news is I managed to get it to build, the bad news is I still have several test
failures, I may take
another look at this later, but feedback from someone who actually understands
the code would be
appreciated.
Index: ipfs-unixfs/Cargo.toml
===================================================================
--- ipfs-unixfs.orig/Cargo.toml
+++ ipfs-unixfs/Cargo.toml
@@ -24,8 +24,9 @@ repository = "https://github.com/rs-ipfs
name = "ingest-tar"
harness = false
[dependencies.cid]
-version = "0.5"
+version = "0.8"
default-features = false
+features = ["std"]
[dependencies.either]
version = "1.5"
@@ -36,8 +37,9 @@ version = "0.2.12"
optional = true
[dependencies.multihash]
-version = "0.11"
+version = "0.16"
default-features = false
+features = ["sha2","multihash-impl"]
[dependencies.quick-protobuf]
version = "0.7"
@@ -45,7 +47,7 @@ features = ["std"]
default-features = false
[dependencies.sha2]
-version = "0.9"
+version = "0.10"
default-features = false
[dev-dependencies.criterion]
version = "0.3"
Index: ipfs-unixfs/src/dir/builder/custom_pb.rs
===================================================================
--- ipfs-unixfs.orig/src/dir/builder/custom_pb.rs
+++ ipfs-unixfs/src/dir/builder/custom_pb.rs
@@ -71,7 +71,7 @@ impl<'a> MessageWrite for WriteableCid<'
use cid::Version::*;
use quick_protobuf::sizeofs::*;
- let hash_len = self.0.hash().as_bytes().len();
+ let hash_len = self.0.hash().to_bytes().len();
match self.0.version() {
V0 => hash_len,
@@ -99,7 +99,7 @@ impl<'a> MessageWrite for WriteableCid<'
self.0
.hash()
- .as_bytes()
+ .to_bytes()
.iter()
// while this looks bad it cannot be measured; note we cannot use the
// write_bytes because that is length prefixed bytes write
Index: ipfs-unixfs/src/dir/builder/iter.rs
===================================================================
--- ipfs-unixfs.orig/src/dir/builder/iter.rs
+++ ipfs-unixfs/src/dir/builder/iter.rs
@@ -4,6 +4,7 @@ use super::{
use cid::Cid;
use core::fmt;
use std::collections::HashMap;
+use multihash::MultihashDigest;
/// Constructs the directory nodes required for a tree.
///
@@ -141,7 +142,7 @@ impl PostOrderIterator {
buffer.truncate(size);
- let mh = multihash::wrap(multihash::Code::Sha2_256, &Sha256::digest(&buffer));
+ let mh = multihash::Code::Sha2_256.wrap(&Sha256::digest(&buffer)).unwrap();
let cid = Cid::new_v0(mh).expect("sha2_256 is the correct multihash for cidv0");
let combined_from_links = links
Index: ipfs-unixfs/src/symlink.rs
===================================================================
--- ipfs-unixfs.orig/src/symlink.rs
+++ ipfs-unixfs/src/symlink.rs
@@ -35,6 +35,7 @@ mod tests {
use cid::Cid;
use core::convert::TryFrom;
use sha2::{Digest, Sha256};
+ use multihash::MultihashDigest;
#[test]
fn simple_symlink() {
@@ -45,7 +46,7 @@ mod tests {
// `foo_directory/b`.
serialize_symlink_block("b", &mut buf);
- let mh = multihash::wrap(multihash::Code::Sha2_256, &Sha256::digest(&buf));
+ let mh = multihash::Code::Sha2_256.wrap(&Sha256::digest(&buf)).unwrap();
let cid = Cid::new_v0(mh).expect("sha2_256 is the correct multihash for cidv0");
assert_eq!(
Index: ipfs-unixfs/src/test_support.rs
===================================================================
--- ipfs-unixfs.orig/src/test_support.rs
+++ ipfs-unixfs/src/test_support.rs
@@ -2,6 +2,7 @@ use cid::Cid;
use core::convert::TryFrom;
use hex_literal::hex;
use std::collections::HashMap;
+use multihash::MultihashDigest;
#[derive(Default)]
pub struct FakeBlockstore {
@@ -29,7 +30,7 @@ impl FakeBlockstore {
sha.update(block);
let result = sha.finalize();
- let mh = multihash::wrap(multihash::Code::Sha2_256, &result[..]);
+ let mh = multihash::Code::Sha2_256.wrap(&result[..]).unwrap();
let cid = Cid::new_v0(mh).unwrap();
assert!(
Index: ipfs-unixfs/src/file/adder.rs
===================================================================
--- ipfs-unixfs.orig/src/file/adder.rs
+++ ipfs-unixfs/src/file/adder.rs
@@ -4,6 +4,7 @@ use crate::pb::{FlatUnixFs, PBLink, Unix
use alloc::borrow::Cow;
use core::fmt;
use quick_protobuf::{MessageWrite, Writer};
+use multihash::MultihashDigest;
use sha2::{Digest, Sha256};
@@ -315,7 +316,7 @@ fn render_and_hash(flat: &FlatUnixFs<'_>
let mut writer = Writer::new(&mut out);
flat.write_message(&mut writer)
.expect("unsure how this could fail");
- let mh = multihash::wrap(multihash::Code::Sha2_256, &Sha256::digest(&out));
+ let mh = multihash::Code::Sha2_256.wrap(&Sha256::digest(&out)).unwrap();
let cid = Cid::new_v0(mh).expect("sha2_256 is the correct multihash for cidv0");
(cid, out)
}
Index: ipfs-unixfs/src/dir/builder/buffered.rs
===================================================================
--- ipfs-unixfs.orig/src/dir/builder/buffered.rs
+++ ipfs-unixfs/src/dir/builder/buffered.rs
@@ -190,6 +190,8 @@ mod tests {
};
use cid::Cid;
use core::convert::TryFrom;
+ use multihash::Hasher;
+ use multihash::MultihashGeneric;
#[test]
fn some_directories() {
@@ -439,7 +441,9 @@ mod tests {
/// Returns a quick and dirty sha2-256 of the given number as a Cidv0
fn some_cid(number: usize) -> Cid {
use multihash::Sha2_256;
- let mh = Sha2_256::digest(&number.to_le_bytes());
+ let mut mh = Sha2_256::default();
+ mh.update(&number.to_le_bytes());
+ let mh = MultihashGeneric::from_bytes(mh.finalize()).unwrap();
Cid::new_v0(mh).unwrap()
}
}
Index: ipfs-unixfs/benches/ingest-tar.rs
===================================================================
--- ipfs-unixfs.orig/benches/ingest-tar.rs
+++ ipfs-unixfs/benches/ingest-tar.rs
@@ -1,4 +1,5 @@
use criterion::{black_box, criterion_group, criterion_main, Criterion};
+use multihash::MultihashDigest;
pub fn criterion_benchmark(c: &mut Criterion) {
let file = "benchmark.tar";
@@ -52,7 +53,7 @@ fn ingest_tar(bytes: &[u8], buffer: &mut
let len = buffer.len();
- let mh = multihash::wrap(multihash::Code::Sha2_256, &Sha256::digest(&buffer));
+ let mh = multihash::Code::Sha2_256.wrap(&Sha256::digest(&buffer)).unwrap();
let cid = Cid::new_v0(mh).expect("sha2_256 is the correct multihash for cidv0");
tree.put_link(&path, cid, len as u64).unwrap();
Index: ipfs-unixfs/examples/add.rs
===================================================================
--- ipfs-unixfs.orig/examples/add.rs
+++ ipfs-unixfs/examples/add.rs
@@ -130,7 +130,7 @@ struct Stats {
impl fmt::Display for Stats {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
let hash = self.last.as_ref().unwrap().hash();
- let cidv1 = Cid::new_v1(cid::Codec::DagProtobuf, hash.to_owned());
+ let cidv1 = Cid::new_v1(0x55, hash.to_owned());
write!(
fmt,
"{} blocks, {} block bytes, {} or {}",
Index: ipfs-unixfs/examples/resolve.rs
===================================================================
--- ipfs-unixfs.orig/examples/resolve.rs
+++ ipfs-unixfs/examples/resolve.rs
@@ -70,7 +70,7 @@ pub enum PathError {
impl fmt::Display for PathError {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
- match *self {
+ match &*self {
PathError::InvalidCid(e) => write!(fmt, "{}", e),
PathError::InvalidPath => write!(fmt, "invalid path"),
}
--- End Message ---