diff --git a/src/block.rs b/src/block.rs index 1bd2249b9..5bcabed28 100644 --- a/src/block.rs +++ b/src/block.rs @@ -103,9 +103,6 @@ impl AsRef<[u8]> for Block { } } -/// Backwards compatible -pub type IpldCodec = BlockCodec; - #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum BlockCodec { /// Raw codec. diff --git a/src/lib.rs b/src/lib.rs index 45558875a..ba88b2f59 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2739,7 +2739,7 @@ mod node { mod tests { use super::*; - use crate::block::IpldCodec; + use crate::block::BlockCodec; use ipld_core::ipld; use multihash_codetable::Code; use multihash_derive::MultihashDigest; @@ -2749,7 +2749,7 @@ mod tests { let ipfs = Node::new("test_node").await; let data = b"hello block\n".to_vec(); - let cid = Cid::new_v1(IpldCodec::Raw.into(), Code::Sha2_256.digest(&data)); + let cid = Cid::new_v1(BlockCodec::Raw.into(), Code::Sha2_256.digest(&data)); let block = Block::new(cid, data).unwrap(); let cid: Cid = ipfs.put_block(block.clone()).await.unwrap(); diff --git a/src/p2p/bitswap.rs b/src/p2p/bitswap.rs index 5da0f5805..4b6b55701 100644 --- a/src/p2p/bitswap.rs +++ b/src/p2p/bitswap.rs @@ -575,7 +575,7 @@ impl NetworkBehaviour for Behaviour { mod test { use std::time::Duration; - use crate::block::IpldCodec; + use crate::block::BlockCodec; use futures::StreamExt; use ipld_core::cid::Cid; use libp2p::{ @@ -589,7 +589,7 @@ mod test { fn create_block() -> Block { let data = b"hello block\n".to_vec(); - let cid = Cid::new_v1(IpldCodec::Raw.into(), Code::Sha2_256.digest(&data)); + let cid = Cid::new_v1(BlockCodec::Raw.into(), Code::Sha2_256.digest(&data)); Block::new_unchecked(cid, data) } diff --git a/src/repo/blockstore/flatfs.rs b/src/repo/blockstore/flatfs.rs index 039e4ec26..66022812e 100644 --- a/src/repo/blockstore/flatfs.rs +++ b/src/repo/blockstore/flatfs.rs @@ -313,7 +313,7 @@ fn write_through_tempfile( #[cfg(test)] mod tests { use super::*; - use crate::block::IpldCodec; + use crate::block::BlockCodec; use crate::Block; use hex_literal::hex; use ipld_core::cid::Cid; @@ -330,7 +330,7 @@ mod tests { let store = FsBlockStore::new(tmp.clone()); let data = b"1".to_vec(); - let cid = Cid::new_v1(IpldCodec::Raw.into(), Code::Sha2_256.digest(&data)); + let cid = Cid::new_v1(BlockCodec::Raw.into(), Code::Sha2_256.digest(&data)); let block = Block::new(cid, data).unwrap(); store.init().await.unwrap(); @@ -367,7 +367,7 @@ mod tests { std::fs::remove_dir_all(&tmp).ok(); let data = b"1".to_vec(); - let cid = Cid::new_v1(IpldCodec::Raw.into(), Code::Sha2_256.digest(&data)); + let cid = Cid::new_v1(BlockCodec::Raw.into(), Code::Sha2_256.digest(&data)); let block = Block::new(cid, data).unwrap(); let block_store = FsBlockStore::new(tmp.clone()); @@ -397,7 +397,7 @@ mod tests { for data in &[b"1", b"2", b"3"] { let data_slice = data.to_vec(); - let cid = Cid::new_v1(IpldCodec::Raw.into(), Code::Sha2_256.digest(&data_slice)); + let cid = Cid::new_v1(BlockCodec::Raw.into(), Code::Sha2_256.digest(&data_slice)); let block = Block::new(cid, data_slice).unwrap(); block_store.put(block.clone()).await.unwrap(); } diff --git a/src/repo/blockstore/memory.rs b/src/repo/blockstore/memory.rs index 1466ce0d2..e6a2e4fad 100644 --- a/src/repo/blockstore/memory.rs +++ b/src/repo/blockstore/memory.rs @@ -131,7 +131,7 @@ impl BlockStore for MemBlockStore { #[cfg(test)] mod tests { use super::*; - use crate::block::IpldCodec; + use crate::block::BlockCodec; use crate::Block; use multihash_codetable::{Code, MultihashDigest}; @@ -140,7 +140,7 @@ mod tests { let tmp = std::env::temp_dir(); let store = MemBlockStore::new(tmp); let data = b"1".to_vec(); - let cid = Cid::new_v1(IpldCodec::Raw.into(), Code::Sha2_256.digest(&data)); + let cid = Cid::new_v1(BlockCodec::Raw.into(), Code::Sha2_256.digest(&data)); let block = Block::new(cid, data).unwrap(); store.init().await.unwrap(); @@ -178,7 +178,7 @@ mod tests { for data in &[b"1", b"2", b"3"] { let data_slice = data.to_vec(); - let cid = Cid::new_v1(IpldCodec::Raw.into(), Code::Sha2_256.digest(&data_slice)); + let cid = Cid::new_v1(BlockCodec::Raw.into(), Code::Sha2_256.digest(&data_slice)); let block = Block::new(cid, data_slice).unwrap(); mem_store.put(block.clone()).await.unwrap(); assert!(mem_store.contains(block.cid()).await.unwrap()); diff --git a/tests/bitswap.rs b/tests/bitswap.rs index 3add4e534..e47e464de 100644 --- a/tests/bitswap.rs +++ b/tests/bitswap.rs @@ -2,7 +2,7 @@ use ipld_core::cid::Cid; mod common; use common::{spawn_nodes, Topology}; -use rust_ipfs::block::IpldCodec; +use rust_ipfs::block::BlockCodec; use rust_ipfs::Block; // this test is designed to trigger unfavorable conditions for the bitswap @@ -21,7 +21,7 @@ async fn bitswap_stress_test() { tracing_subscriber::fmt::init(); let data = b"hello block\n".to_vec(); - let cid = Cid::new_v1(IpldCodec::Raw.into(), Code::Sha2_256.digest(&data)); + let cid = Cid::new_v1(BlockCodec::Raw.into(), Code::Sha2_256.digest(&data)); let nodes = spawn_nodes::<5>(Topology::Mesh).await; diff --git a/tests/block_exchange.rs b/tests/block_exchange.rs index 54d8589c7..9b674af56 100644 --- a/tests/block_exchange.rs +++ b/tests/block_exchange.rs @@ -6,11 +6,11 @@ use std::time::Duration; mod common; use common::{spawn_nodes, Topology}; -use rust_ipfs::block::IpldCodec; +use rust_ipfs::block::BlockCodec; fn create_block() -> Block { let data = b"hello block\n".to_vec(); - let cid = Cid::new_v1(IpldCodec::Raw.into(), Code::Sha2_256.digest(&data)); + let cid = Cid::new_v1(BlockCodec::Raw.into(), Code::Sha2_256.digest(&data)); Block::new_unchecked(cid, data) } diff --git a/tests/gc.rs b/tests/gc.rs index eec18093b..d99b29a91 100644 --- a/tests/gc.rs +++ b/tests/gc.rs @@ -1,11 +1,11 @@ use ipld_core::cid::Cid; use multihash_codetable::{Code, MultihashDigest}; -use rust_ipfs::block::IpldCodec; +use rust_ipfs::block::BlockCodec; use rust_ipfs::{Block, Node}; fn create_block() -> Block { let data = b"hello block\n".to_vec(); - let cid = Cid::new_v1(IpldCodec::Raw.into(), Code::Sha2_256.digest(&data)); + let cid = Cid::new_v1(BlockCodec::Raw.into(), Code::Sha2_256.digest(&data)); Block::new_unchecked(cid, data) } diff --git a/tests/kademlia.rs b/tests/kademlia.rs index b8ce0c452..14daae3ce 100644 --- a/tests/kademlia.rs +++ b/tests/kademlia.rs @@ -9,7 +9,7 @@ use std::time::Duration; mod common; use common::{interop::ForeignNode, spawn_nodes, Topology}; -use rust_ipfs::block::IpldCodec; +use rust_ipfs::block::BlockCodec; fn strip_peer_id(mut addr: Multiaddr) -> Multiaddr { addr.extract_peer_id().expect("Peer id exist"); @@ -165,7 +165,7 @@ async fn dht_providing() { // the last node puts a block in order to have something to provide let data = b"hello block\n".to_vec(); - let cid = Cid::new_v1(IpldCodec::Raw.into(), Code::Sha2_256.digest(&data)); + let cid = Cid::new_v1(BlockCodec::Raw.into(), Code::Sha2_256.digest(&data)); nodes[last_index] .put_block(Block::new(cid, data).unwrap()) .await