mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
Move FileClient and BlockFileCodec out of test-utils (#5998)
Co-authored-by: Dan Cline <6798349+Rjected@users.noreply.github.com>
This commit is contained in:
@ -38,9 +38,9 @@ thiserror.workspace = true
|
||||
|
||||
# optional deps for the test-utils feature
|
||||
reth-db = { workspace = true, optional = true }
|
||||
alloy-rlp = { workspace = true, optional = true }
|
||||
alloy-rlp.workspace = true
|
||||
tempfile = { workspace = true, optional = true }
|
||||
itertools = { workspace = true, optional = true }
|
||||
itertools.workspace = true
|
||||
|
||||
[dev-dependencies]
|
||||
reth-db = { workspace = true, features = ["test-utils"] }
|
||||
@ -55,4 +55,5 @@ itertools.workspace = true
|
||||
tempfile.workspace = true
|
||||
|
||||
[features]
|
||||
test-utils = ["dep:alloy-rlp", "dep:tempfile", "dep:itertools", "reth-db/test-utils", "reth-interfaces/test-utils"]
|
||||
test-utils = ["dep:tempfile", "reth-db/test-utils", "reth-interfaces/test-utils"]
|
||||
|
||||
|
||||
@ -127,13 +127,13 @@ impl FileClient {
|
||||
}
|
||||
|
||||
/// Use the provided bodies as the file client's block body buffer.
|
||||
pub(crate) fn with_bodies(mut self, bodies: HashMap<BlockHash, BlockBody>) -> Self {
|
||||
pub fn with_bodies(mut self, bodies: HashMap<BlockHash, BlockBody>) -> Self {
|
||||
self.bodies = bodies;
|
||||
self
|
||||
}
|
||||
|
||||
/// Use the provided headers as the file client's block body buffer.
|
||||
pub(crate) fn with_headers(mut self, headers: HashMap<BlockNumber, Header>) -> Self {
|
||||
pub fn with_headers(mut self, headers: HashMap<BlockNumber, Header>) -> Self {
|
||||
self.headers = headers;
|
||||
for (number, header) in &self.headers {
|
||||
self.hash_to_number.insert(header.hash_slow(), *number);
|
||||
@ -1,6 +1,6 @@
|
||||
//! Codec for reading raw block bodies from a file.
|
||||
|
||||
use super::FileClientError;
|
||||
use crate::file_client::FileClientError;
|
||||
use alloy_rlp::{Decodable, Encodable};
|
||||
use reth_primitives::{
|
||||
bytes::{Buf, BytesMut},
|
||||
@ -20,5 +20,16 @@ pub mod headers;
|
||||
/// Common downloader metrics.
|
||||
pub mod metrics;
|
||||
|
||||
/// Module managing file-based data retrieval and buffering.
|
||||
///
|
||||
/// Contains [FileClient](file_client::FileClient) to read block data from files,
|
||||
/// efficiently buffering headers and bodies for retrieval.
|
||||
pub mod file_client;
|
||||
|
||||
/// Module with a codec for reading and encoding block bodies in files.
|
||||
///
|
||||
/// Enables decoding and encoding `Block` types within file contexts.
|
||||
pub mod file_codec;
|
||||
|
||||
#[cfg(any(test, feature = "test-utils"))]
|
||||
pub mod test_utils;
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
#![allow(dead_code)]
|
||||
|
||||
use crate::bodies::test_utils::create_raw_bodies;
|
||||
use crate::{bodies::test_utils::create_raw_bodies, file_codec::BlockFileCodec};
|
||||
use futures::SinkExt;
|
||||
use reth_interfaces::test_utils::{generators, generators::random_block_range};
|
||||
use reth_primitives::{BlockBody, SealedHeader, B256};
|
||||
@ -13,12 +13,6 @@ use tokio_util::codec::FramedWrite;
|
||||
mod bodies_client;
|
||||
pub use bodies_client::TestBodiesClient;
|
||||
|
||||
mod file_client;
|
||||
pub use file_client::{FileClient, FileClientError};
|
||||
|
||||
mod file_codec;
|
||||
pub(crate) use file_codec::BlockFileCodec;
|
||||
|
||||
/// Metrics scope used for testing.
|
||||
pub(crate) const TEST_SCOPE: &str = "downloaders.test";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user