mirror of
https://github.com/Cuprate/cuprate.git
synced 2024-12-23 12:09:52 +00:00
size
-> bytes
This commit is contained in:
parent
509d5cbde2
commit
c947cf6efe
3 changed files with 18 additions and 18 deletions
|
@ -23,22 +23,22 @@ pub struct P2PConfig {
|
||||||
pub struct BlockDownloaderConfig {
|
pub struct BlockDownloaderConfig {
|
||||||
/// The size in bytes of the buffer between the block downloader and the place which
|
/// The size in bytes of the buffer between the block downloader and the place which
|
||||||
/// is consuming the downloaded blocks.
|
/// 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.
|
/// 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.
|
/// The [`Duration`] between checking the client pool for free peers.
|
||||||
pub check_client_pool_interval: Duration,
|
pub check_client_pool_interval: Duration,
|
||||||
/// The target size of a single batch of blocks (in bytes).
|
/// The target size of a single batch of blocks (in bytes).
|
||||||
pub target_batch_size: usize,
|
pub target_batch_bytes: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<BlockDownloaderConfig> for cuprate_p2p::block_downloader::BlockDownloaderConfig {
|
impl From<BlockDownloaderConfig> for cuprate_p2p::block_downloader::BlockDownloaderConfig {
|
||||||
fn from(value: BlockDownloaderConfig) -> Self {
|
fn from(value: BlockDownloaderConfig) -> Self {
|
||||||
Self {
|
Self {
|
||||||
buffer_size: value.buffer_size,
|
buffer_bytes: value.buffer_bytes,
|
||||||
in_progress_queue_size: value.in_progress_queue_size,
|
in_progress_queue_bytes: value.in_progress_queue_bytes,
|
||||||
check_client_pool_interval: value.check_client_pool_interval,
|
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,
|
initial_batch_len: 1,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,10 +47,10 @@ impl From<BlockDownloaderConfig> for cuprate_p2p::block_downloader::BlockDownloa
|
||||||
impl Default for BlockDownloaderConfig {
|
impl Default for BlockDownloaderConfig {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
buffer_size: 50_000_000,
|
buffer_bytes: 50_000_000,
|
||||||
in_progress_queue_size: 50_000_000,
|
in_progress_queue_bytes: 50_000_000,
|
||||||
check_client_pool_interval: Duration::from_secs(30),
|
check_client_pool_interval: Duration::from_secs(30),
|
||||||
target_batch_size: 5_000_000,
|
target_batch_bytes: 5_000_000,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,13 +62,13 @@ pub struct BlockBatch {
|
||||||
pub struct BlockDownloaderConfig {
|
pub struct BlockDownloaderConfig {
|
||||||
/// The size in bytes of the buffer between the block downloader and the place which
|
/// The size in bytes of the buffer between the block downloader and the place which
|
||||||
/// is consuming the downloaded blocks.
|
/// 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.
|
/// 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.
|
/// The [`Duration`] between checking the client pool for free peers.
|
||||||
pub check_client_pool_interval: Duration,
|
pub check_client_pool_interval: Duration,
|
||||||
/// The target size of a single batch of blocks (in bytes).
|
/// 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)
|
/// The initial amount of blocks to request (in number of blocks)
|
||||||
pub initial_batch_len: usize,
|
pub initial_batch_len: usize,
|
||||||
}
|
}
|
||||||
|
@ -145,7 +145,7 @@ where
|
||||||
+ 'static,
|
+ 'static,
|
||||||
C::Future: Send + '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 =
|
let block_downloader =
|
||||||
BlockDownloader::new(client_pool, our_chain_svc, buffer_appender, config);
|
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 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);
|
return self.request_inflight_batch_again(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -557,7 +557,7 @@ where
|
||||||
self.amount_of_blocks_to_request = calculate_next_block_batch_size(
|
self.amount_of_blocks_to_request = calculate_next_block_batch_size(
|
||||||
block_batch.size,
|
block_batch.size,
|
||||||
block_batch.blocks.len(),
|
block_batch.blocks.len(),
|
||||||
self.config.target_batch_size,
|
self.config.target_batch_bytes,
|
||||||
);
|
);
|
||||||
|
|
||||||
tracing::debug!(
|
tracing::debug!(
|
||||||
|
|
|
@ -65,10 +65,10 @@ proptest! {
|
||||||
genesis: *blockchain.blocks.first().unwrap().0
|
genesis: *blockchain.blocks.first().unwrap().0
|
||||||
},
|
},
|
||||||
BlockDownloaderConfig {
|
BlockDownloaderConfig {
|
||||||
buffer_size: 1_000,
|
buffer_bytes: 1_000,
|
||||||
in_progress_queue_size: 10_000,
|
in_progress_queue_bytes: 10_000,
|
||||||
check_client_pool_interval: Duration::from_secs(5),
|
check_client_pool_interval: Duration::from_secs(5),
|
||||||
target_batch_size: 5_000,
|
target_batch_bytes: 5_000,
|
||||||
initial_batch_len: 1,
|
initial_batch_len: 1,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue