From c0f88ede8eed3fb371bb6259dfee979d5b3fba07 Mon Sep 17 00:00:00 2001 From: Alfredo Garcia Date: Mon, 1 Jan 2024 20:21:22 -0300 Subject: [PATCH] make bulk size the same for testnet and mainnet (#8127) --- zebra-state/src/service/finalized_state.rs | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/zebra-state/src/service/finalized_state.rs b/zebra-state/src/service/finalized_state.rs index 0fc76b8a3..7ca3d40d1 100644 --- a/zebra-state/src/service/finalized_state.rs +++ b/zebra-state/src/service/finalized_state.rs @@ -458,15 +458,11 @@ impl FinalizedState { let block_time = block.header.time.timestamp(); let local_time = chrono::Utc::now().timestamp(); - // Mainnet bulk size is small enough to avoid the elasticsearch 100mb content - // length limitation. MAX_BLOCK_BYTES = 2MB but each block use around 4.1 MB of JSON. + // Bulk size is small enough to avoid the elasticsearch 100mb content length limitation. + // MAX_BLOCK_BYTES = 2MB but each block use around 4.1 MB of JSON. // Each block count as 2 as we send them with a operation/header line. A value of 48 // is 24 blocks. - const MAINNET_AWAY_FROM_TIP_BULK_SIZE: usize = 48; - - // Testnet bulk size is larger as blocks are generally smaller in the testnet. - // A value of 800 is 400 blocks as we are not counting the operation line. - const TESTNET_AWAY_FROM_TIP_BULK_SIZE: usize = 800; + const AWAY_FROM_TIP_BULK_SIZE: usize = 48; // The number of blocks the bulk will have when we are in sync. // A value of 2 means only 1 block as we want to insert them as soon as we get @@ -477,10 +473,7 @@ impl FinalizedState { // less than this number of seconds. const CLOSE_TO_TIP_SECONDS: i64 = 14400; // 4 hours - let mut blocks_size_to_dump = match self.network() { - Network::Mainnet => MAINNET_AWAY_FROM_TIP_BULK_SIZE, - Network::Testnet => TESTNET_AWAY_FROM_TIP_BULK_SIZE, - }; + let mut blocks_size_to_dump = AWAY_FROM_TIP_BULK_SIZE; // If we are close to the tip, index one block per bulk call. if local_time - block_time < CLOSE_TO_TIP_SECONDS {