net: replace reth-primitive imports (#11023)

This commit is contained in:
Håvard Anda Estensen
2024-09-19 10:29:01 +02:00
committed by GitHub
parent 883975dc90
commit ae9b13f4a1
59 changed files with 139 additions and 96 deletions

View File

@ -26,7 +26,8 @@ reth-db = { workspace = true, optional = true }
reth-db-api = { workspace = true, optional = true }
reth-testing-utils = { workspace = true, optional = true }
# eth
# ethereum
alloy-primitives.workspace = true
alloy-rlp.workspace = true
# async

View File

@ -1,5 +1,6 @@
use super::queue::BodiesRequestQueue;
use crate::{bodies::task::TaskDownloader, metrics::BodyDownloaderMetrics};
use alloy_primitives::BlockNumber;
use futures::Stream;
use futures_util::StreamExt;
use reth_config::BodiesConfig;
@ -12,7 +13,7 @@ use reth_network_p2p::{
},
error::{DownloadError, DownloadResult},
};
use reth_primitives::{BlockNumber, SealedHeader};
use reth_primitives::SealedHeader;
use reth_storage_api::HeaderProvider;
use reth_tasks::{TaskSpawner, TokioTaskExecutor};
use std::{
@ -601,11 +602,12 @@ mod tests {
bodies::test_utils::{insert_headers, zip_blocks},
test_utils::{generate_bodies, TestBodiesClient},
};
use alloy_primitives::B256;
use assert_matches::assert_matches;
use reth_chainspec::MAINNET;
use reth_consensus::test_utils::TestConsensus;
use reth_db::test_utils::{create_test_rw_db, create_test_static_files_dir};
use reth_primitives::{BlockBody, B256};
use reth_primitives::BlockBody;
use reth_provider::{
providers::StaticFileProvider, test_utils::MockNodeTypesWithDB, ProviderFactory,
};

View File

@ -1,9 +1,9 @@
use alloy_primitives::BlockNumber;
use futures::Stream;
use reth_network_p2p::{
bodies::{downloader::BodyDownloader, response::BlockResponse},
error::{DownloadError, DownloadResult},
};
use reth_primitives::BlockNumber;
use std::ops::RangeInclusive;
/// A [`BodyDownloader`] implementation that does nothing.

View File

@ -1,5 +1,6 @@
use super::request::BodiesRequestFuture;
use crate::metrics::BodyDownloaderMetrics;
use alloy_primitives::BlockNumber;
use futures::{stream::FuturesUnordered, Stream};
use futures_util::StreamExt;
use reth_consensus::Consensus;
@ -7,7 +8,7 @@ use reth_network_p2p::{
bodies::{client::BodiesClient, response::BlockResponse},
error::DownloadResult,
};
use reth_primitives::{BlockNumber, SealedHeader};
use reth_primitives::SealedHeader;
use std::{
pin::Pin,
sync::Arc,

View File

@ -1,4 +1,5 @@
use crate::metrics::{BodyDownloaderMetrics, ResponseMetrics};
use alloy_primitives::B256;
use futures::{Future, FutureExt};
use reth_consensus::Consensus;
use reth_network_p2p::{
@ -7,7 +8,7 @@ use reth_network_p2p::{
priority::Priority,
};
use reth_network_peers::{PeerId, WithPeerId};
use reth_primitives::{BlockBody, GotExpected, SealedBlock, SealedHeader, B256};
use reth_primitives::{BlockBody, GotExpected, SealedBlock, SealedHeader};
use std::{
collections::VecDeque,
mem,

View File

@ -1,3 +1,4 @@
use alloy_primitives::BlockNumber;
use futures::Stream;
use futures_util::{FutureExt, StreamExt};
use pin_project::pin_project;
@ -5,7 +6,6 @@ use reth_network_p2p::{
bodies::downloader::{BodyDownloader, BodyDownloaderResult},
error::DownloadResult,
};
use reth_primitives::BlockNumber;
use reth_tasks::{TaskSpawner, TokioTaskExecutor};
use std::{
future::Future,

View File

@ -2,10 +2,11 @@
#![allow(dead_code)]
use alloy_primitives::B256;
use reth_db::{tables, DatabaseEnv};
use reth_db_api::{database::Database, transaction::DbTxMut};
use reth_network_p2p::bodies::response::BlockResponse;
use reth_primitives::{Block, BlockBody, SealedBlock, SealedHeader, B256};
use reth_primitives::{Block, BlockBody, SealedBlock, SealedHeader};
use std::collections::HashMap;
pub(crate) fn zip_blocks<'a>(

View File

@ -1,5 +1,6 @@
use std::{collections::HashMap, io, path::Path};
use alloy_primitives::{BlockHash, BlockNumber, B256};
use futures::Future;
use itertools::Either;
use reth_network_p2p::{
@ -10,9 +11,7 @@ use reth_network_p2p::{
priority::Priority,
};
use reth_network_peers::PeerId;
use reth_primitives::{
BlockBody, BlockHash, BlockHashOrNumber, BlockNumber, Header, SealedHeader, B256,
};
use reth_primitives::{BlockBody, BlockHashOrNumber, Header, SealedHeader};
use thiserror::Error;
use tokio::{fs::File, io::AsyncReadExt};
use tokio_stream::StreamExt;

View File

@ -1,11 +1,9 @@
//! Codec for reading raw block bodies from a file.
use crate::file_client::FileClientError;
use alloy_primitives::bytes::{Buf, BytesMut};
use alloy_rlp::{Decodable, Encodable};
use reth_primitives::{
bytes::{Buf, BytesMut},
Block,
};
use reth_primitives::Block;
use tokio_util::codec::{Decoder, Encoder};
/// Codec for reading raw block bodies from a file.

View File

@ -2,6 +2,7 @@
use super::task::TaskDownloader;
use crate::metrics::HeaderDownloaderMetrics;
use alloy_primitives::{BlockNumber, B256};
use futures::{stream::Stream, FutureExt};
use futures_util::{stream::FuturesUnordered, StreamExt};
use rayon::prelude::*;
@ -17,7 +18,7 @@ use reth_network_p2p::{
priority::Priority,
};
use reth_network_peers::PeerId;
use reth_primitives::{BlockHashOrNumber, BlockNumber, GotExpected, Header, SealedHeader, B256};
use reth_primitives::{BlockHashOrNumber, GotExpected, Header, SealedHeader};
use reth_tasks::{TaskSpawner, TokioTaskExecutor};
use std::{
cmp::{Ordering, Reverse},

View File

@ -208,10 +208,9 @@ pub struct ReceiptWithBlockNumber {
#[cfg(test)]
mod test {
use alloy_primitives::{hex, Address, Bytes, Log, LogData, B256};
use alloy_rlp::{Decodable, RlpDecodable};
use reth_primitives::{
hex, Address, Buf, Bytes, BytesMut, Log, LogData, Receipt, TxType, B256,
};
use reth_primitives::{Buf, BytesMut, Receipt, TxType};
use reth_tracing::init_test_tracing;
use tokio_util::codec::Decoder;

View File

@ -1,10 +1,11 @@
use alloy_primitives::B256;
use reth_network_p2p::{
bodies::client::{BodiesClient, BodiesFut},
download::DownloadClient,
priority::Priority,
};
use reth_network_peers::PeerId;
use reth_primitives::{BlockBody, B256};
use reth_primitives::BlockBody;
use std::{
collections::HashMap,
fmt::Debug,

View File

@ -3,8 +3,9 @@
#![allow(dead_code)]
use crate::{bodies::test_utils::create_raw_bodies, file_codec::BlockFileCodec};
use alloy_primitives::B256;
use futures::SinkExt;
use reth_primitives::{BlockBody, SealedHeader, B256};
use reth_primitives::{BlockBody, SealedHeader};
use reth_testing_utils::generators::{self, random_block_range, BlockRangeParams};
use std::{collections::HashMap, io::SeekFrom, ops::RangeInclusive};
use tokio::{fs::File, io::AsyncSeekExt};