exocore_chain/engine/chain_sync/
config.rs

1use crate::{block::BlockHeight, engine::request_tracker};
2
3/// Chain synchronizer's configuration
4#[derive(Clone, Debug)]
5pub struct ChainSyncConfig {
6    /// Config for requests timing tracker
7    pub request_tracker: request_tracker::RequestTrackerConfig,
8
9    /// Maximum number of synchronization failures before considering a node
10    /// offsync
11    pub meta_sync_max_failures: usize,
12
13    /// Number of blocks metadata to always include at beginning of a metadata
14    /// sync request
15    pub metadata_sync_begin_count: usize,
16
17    /// Number of blocks metadata to always include at end of a metadata sync
18    /// request
19    pub metadata_sync_end_count: usize,
20
21    /// Number of sampled blocks metadata to include between begin and end
22    /// blocks of a metadata sync request
23    pub metadata_sync_sampled_count: usize,
24
25    /// When doing blocks metadata synchronization, if the requested range spans
26    /// multiple segments, this is the threshold from which we fall into a
27    /// fast synchronization mode. Instead of sampling blocks, only the
28    /// first block of each segments (segments boundary) is sent preventing
29    /// scanning blocks.
30    pub metadata_sync_segments_boundaries_threshold: usize,
31
32    /// Maximum number of bytes worth of blocks to send in a response
33    /// This should be lower than transport maximum packet size
34    pub blocks_max_send_size: usize,
35
36    /// Maximum height in blocks that we can tolerate between our common
37    /// ancestor block and its latest block. If it gets higher than this
38    /// value, this means that we may have diverged and we need to
39    /// re-synchronize.
40    pub max_leader_common_block_height_delta: BlockHeight,
41}
42
43impl Default for ChainSyncConfig {
44    fn default() -> Self {
45        ChainSyncConfig {
46            request_tracker: request_tracker::RequestTrackerConfig::default(),
47            meta_sync_max_failures: 2,
48            metadata_sync_begin_count: 5,
49            metadata_sync_end_count: 5,
50            metadata_sync_sampled_count: 10,
51            metadata_sync_segments_boundaries_threshold: 5,
52            blocks_max_send_size: 2 * 1024 * 1024, // 2mb
53            max_leader_common_block_height_delta: 5,
54        }
55    }
56}