Skip to content

Commit

Permalink
chore: remove type alias
Browse files Browse the repository at this point in the history
  • Loading branch information
dariusc93 committed Jul 5, 2024
1 parent c9d4a09 commit 7add7b5
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 22 deletions.
3 changes: 0 additions & 3 deletions src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions src/p2p/bitswap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand All @@ -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)
}
Expand Down
8 changes: 4 additions & 4 deletions src/repo/blockstore/flatfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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();
}
Expand Down
6 changes: 3 additions & 3 deletions src/repo/blockstore/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand All @@ -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();
Expand Down Expand Up @@ -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());
Expand Down
4 changes: 2 additions & 2 deletions tests/bitswap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions tests/block_exchange.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions tests/gc.rs
Original file line number Diff line number Diff line change
@@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions tests/kademlia.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 7add7b5

Please sign in to comment.