diff --git a/binaries/cuprated/src/config/p2p.rs b/binaries/cuprated/src/config/p2p.rs index aaf7dda7..5a3d5008 100644 --- a/binaries/cuprated/src/config/p2p.rs +++ b/binaries/cuprated/src/config/p2p.rs @@ -23,22 +23,22 @@ pub struct P2PConfig { pub struct BlockDownloaderConfig { /// The size in bytes of the buffer between the block downloader and the place which /// is consuming the downloaded blocks. - pub buffer_size: usize, + pub buffer_bytes: usize, /// The size of the in progress queue (in bytes) at which we stop requesting more blocks. - pub in_progress_queue_size: usize, + pub in_progress_queue_bytes: usize, /// The [`Duration`] between checking the client pool for free peers. pub check_client_pool_interval: Duration, /// The target size of a single batch of blocks (in bytes). - pub target_batch_size: usize, + pub target_batch_bytes: usize, } impl From for cuprate_p2p::block_downloader::BlockDownloaderConfig { fn from(value: BlockDownloaderConfig) -> Self { Self { - buffer_size: value.buffer_size, - in_progress_queue_size: value.in_progress_queue_size, + buffer_bytes: value.buffer_bytes, + in_progress_queue_bytes: value.in_progress_queue_bytes, check_client_pool_interval: value.check_client_pool_interval, - target_batch_size: value.target_batch_size, + target_batch_bytes: value.target_batch_bytes, initial_batch_len: 1, } } @@ -47,10 +47,10 @@ impl From for cuprate_p2p::block_downloader::BlockDownloa impl Default for BlockDownloaderConfig { fn default() -> Self { Self { - buffer_size: 50_000_000, - in_progress_queue_size: 50_000_000, + buffer_bytes: 50_000_000, + in_progress_queue_bytes: 50_000_000, check_client_pool_interval: Duration::from_secs(30), - target_batch_size: 5_000_000, + target_batch_bytes: 5_000_000, } } } diff --git a/p2p/p2p/src/block_downloader.rs b/p2p/p2p/src/block_downloader.rs index 5ebcedc0..86bf4326 100644 --- a/p2p/p2p/src/block_downloader.rs +++ b/p2p/p2p/src/block_downloader.rs @@ -62,13 +62,13 @@ pub struct BlockBatch { pub struct BlockDownloaderConfig { /// The size in bytes of the buffer between the block downloader and the place which /// is consuming the downloaded blocks. - pub buffer_size: usize, + pub buffer_bytes: usize, /// The size of the in progress queue (in bytes) at which we stop requesting more blocks. - pub in_progress_queue_size: usize, + pub in_progress_queue_bytes: usize, /// The [`Duration`] between checking the client pool for free peers. pub check_client_pool_interval: Duration, /// The target size of a single batch of blocks (in bytes). - pub target_batch_size: usize, + pub target_batch_bytes: usize, /// The initial amount of blocks to request (in number of blocks) pub initial_batch_len: usize, } @@ -145,7 +145,7 @@ where + 'static, C::Future: Send + 'static, { - let (buffer_appender, buffer_stream) = cuprate_async_buffer::new_buffer(config.buffer_size); + let (buffer_appender, buffer_stream) = cuprate_async_buffer::new_buffer(config.buffer_bytes); let block_downloader = BlockDownloader::new(client_pool, our_chain_svc, buffer_appender, config); @@ -382,7 +382,7 @@ where } // If our ready queue is too large send duplicate requests for the blocks we are waiting on. - if self.block_queue.size() >= self.config.in_progress_queue_size { + if self.block_queue.size() >= self.config.in_progress_queue_bytes { return self.request_inflight_batch_again(client); } @@ -557,7 +557,7 @@ where self.amount_of_blocks_to_request = calculate_next_block_batch_size( block_batch.size, block_batch.blocks.len(), - self.config.target_batch_size, + self.config.target_batch_bytes, ); tracing::debug!( diff --git a/p2p/p2p/src/block_downloader/tests.rs b/p2p/p2p/src/block_downloader/tests.rs index dd07cce9..2846c1d2 100644 --- a/p2p/p2p/src/block_downloader/tests.rs +++ b/p2p/p2p/src/block_downloader/tests.rs @@ -65,10 +65,10 @@ proptest! { genesis: *blockchain.blocks.first().unwrap().0 }, BlockDownloaderConfig { - buffer_size: 1_000, - in_progress_queue_size: 10_000, + buffer_bytes: 1_000, + in_progress_queue_bytes: 10_000, check_client_pool_interval: Duration::from_secs(5), - target_batch_size: 5_000, + target_batch_bytes: 5_000, initial_batch_len: 1, });