Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Remove dead code detected by the rust beta compiler #2121

Merged
merged 2 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 3 additions & 40 deletions iroh-bytes/src/store/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
use std::{collections::BTreeSet, io, path::PathBuf};

use bao_tree::{
io::fsm::{BaoContentItem, Outboard, OutboardMut},
io::fsm::{BaoContentItem, Outboard},
BaoTree, ByteNum, ChunkRanges,
};
use bytes::Bytes;
use futures::{future, Future, Stream, StreamExt};
use futures::{Future, Stream, StreamExt};
use genawaiter::rc::{Co, Gen};
use iroh_base::rpc::RpcError;
use iroh_io::{AsyncSliceReader, AsyncSliceWriter};
use iroh_io::AsyncSliceReader;
use serde::{Deserialize, Serialize};
use tokio::io::AsyncRead;
use tokio_util::task::LocalPoolHandle;
Expand Down Expand Up @@ -216,43 +216,6 @@ impl<W: BaoBatchWriter, F: Fn(u64, usize) -> io::Result<()> + 'static> BaoBatchW
}
}

/// A combined batch writer
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this is dead since we have a proper batch writer. In some branch I removed this already.

///
/// This is just temporary to allow reusing the existing store implementations
/// that have separate data and outboard writers.
#[derive(Debug)]
pub(crate) struct CombinedBatchWriter<D, O> {
/// data part
pub data: D,
/// outboard part
pub outboard: O,
}

impl<D, O> BaoBatchWriter for CombinedBatchWriter<D, O>
where
D: AsyncSliceWriter,
O: OutboardMut,
{
async fn write_batch(&mut self, _size: u64, batch: Vec<BaoContentItem>) -> io::Result<()> {
for item in batch {
match item {
BaoContentItem::Parent(parent) => {
self.outboard.save(parent.node, &parent.pair).await?;
}
BaoContentItem::Leaf(leaf) => {
self.data.write_bytes_at(leaf.offset.0, leaf.data).await?;
}
}
}
Ok(())
}

async fn sync(&mut self) -> io::Result<()> {
future::try_join(self.data.sync(), self.outboard.sync()).await?;
Ok(())
}
}

/// A mutable bao map.
///
/// This extends the readonly [`Map`] trait with methods to create and modify entries.
Expand Down
4 changes: 0 additions & 4 deletions iroh-net/src/relay/client_conn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use std::time::Duration;
use anyhow::{Context, Result};
use bytes::Bytes;
use futures::{SinkExt, StreamExt};
use tokio::io::{AsyncRead, AsyncWrite};
use tokio::sync::mpsc;
use tokio_util::codec::Framed;
use tokio_util::sync::CancellationToken;
Expand Down Expand Up @@ -68,9 +67,6 @@ pub(crate) struct ClientChannels {
pub(crate) peer_gone: mpsc::Sender<PublicKey>,
}

pub trait Io: AsyncRead + AsyncWrite + Unpin + std::fmt::Debug {}
impl<T: AsyncRead + AsyncWrite + Unpin + std::fmt::Debug> Io for T {}

/// A builds a [`ClientConnManager`] from a [`PublicKey`] and an io connection.
#[derive(Debug)]
pub struct ClientConnBuilder {
Expand Down
2 changes: 2 additions & 0 deletions iroh-sync/src/ranger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ pub trait RangeEntry: Debug + Clone {
/// A trait constraining types that are valid entry keys.
pub trait RangeKey: Sized + Debug + Ord + PartialEq + Clone + 'static {
/// Returns `true` if `self` is a prefix of `other`.
#[cfg(test)]
fn is_prefix_of(&self, other: &Self) -> bool;

/// Returns true if `other` is a prefix of `self`.
#[cfg(test)]
fn is_prefixed_by(&self, other: &Self) -> bool {
other.is_prefix_of(self)
}
Expand Down
1 change: 1 addition & 0 deletions iroh-sync/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -974,6 +974,7 @@ impl Debug for RecordIdentifier {
}

impl RangeKey for RecordIdentifier {
#[cfg(test)]
fn is_prefix_of(&self, other: &Self) -> bool {
other.as_ref().starts_with(self.as_ref())
}
Expand Down
21 changes: 0 additions & 21 deletions iroh/src/util/io.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! Utilities for working with tokio io
use bao_tree::io::EncodeError;
use derive_more::Display;
use std::io::Write;
use thiserror::Error;

/// Todo: gather more information about validation errors. E.g. offset
Expand All @@ -14,23 +13,3 @@ pub enum BaoValidationError {
/// The data failed to validate
EncodeError(#[from] EncodeError),
}

/// little util that discards data but prints progress every 1MB
struct DevNull<F>(u64, F);

impl<F: Fn(u64)> Write for DevNull<F> {
fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
const NOTIFY_EVERY: u64 = 1024 * 1024;
let prev = self.0;
let curr = prev + buf.len() as u64;
if prev % NOTIFY_EVERY != curr % NOTIFY_EVERY {
(self.1)(curr);
}
self.0 = curr;
Ok(buf.len())
}

fn flush(&mut self) -> std::io::Result<()> {
Ok(())
}
}
Loading