• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

tari-project / tari / 18709590933

22 Oct 2025 08:06AM UTC coverage: 59.567% (+0.02%) from 59.549%
18709590933

push

github

SWvheerden
chore: new release v5.2.0-pre.0

67657 of 113581 relevant lines covered (59.57%)

229236.91 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/base_layer/core/src/base_node/sync/config.rs
1
//  Copyright 2020, The Tari Project
2
//
3
//  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
4
//  following conditions are met:
5
//
6
//  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
7
//  disclaimer.
8
//
9
//  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
10
//  following disclaimer in the documentation and/or other materials provided with the distribution.
11
//
12
//  3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote
13
//  products derived from this software without specific prior written permission.
14
//
15
//  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
16
//  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17
//  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
18
//  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19
//  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
20
//  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
21
//  USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22

23
use std::time::Duration;
24

25
use serde::{Deserialize, Serialize};
26
use tari_common::configuration::serializers;
27
use tari_comms::peer_manager::NodeId;
28
#[derive(Debug, Clone, Serialize, Deserialize)]
29
#[serde(deny_unknown_fields)]
30
pub struct BlockchainSyncConfig {
31
    /// The initial max sync latency. If a peer fails to stream a header/block within this deadline another sync peer
32
    /// will be selected. If there are no further peers the sync will be restarted with an increased by
33
    /// `max_latency_increase`.
34
    #[serde(with = "serializers::seconds")]
35
    pub initial_max_sync_latency: Duration,
36
    /// If all sync peers exceed latency, increase allowed latency by this value
37
    #[serde(with = "serializers::seconds")]
38
    pub max_latency_increase: Duration,
39
    /// Longer ban period for potentially malicious infractions (protocol violations etc.)
40
    #[serde(with = "serializers::seconds")]
41
    pub ban_period: Duration,
42
    /// Short ban period for infractions that are likely not malicious (slow to respond, spotty connections etc)
43
    #[serde(with = "serializers::seconds")]
44
    pub short_ban_period: Duration,
45
    /// An allowlist of sync peers from which to sync. No other peers will be selected for sync. If empty, sync peers
46
    /// are chosen based on their advertised chain metadata.
47
    pub forced_sync_peers: Vec<NodeId>,
48
    /// Number of threads to use for validation
49
    pub validation_concurrency: usize,
50
    /// The RPC deadline to set on sync clients. If this deadline is reached, a new sync peer will be selected for
51
    /// sync.
52
    #[serde(with = "serializers::seconds")]
53
    pub rpc_deadline: Duration,
54
    /// The number of initial rounds of seed peer based bootstrapping.
55
    #[serde(default = "default_num_initial_sync_rounds_seed_bootstrap")]
56
    pub num_initial_sync_rounds_seed_bootstrap: usize,
57
    /// The maximum reorg depth allowed during header synchronization.
58
    #[serde(default = "max_reorg_depth_allowed")]
59
    pub max_reorg_depth_allowed: usize,
60
}
61

62
fn default_num_initial_sync_rounds_seed_bootstrap() -> usize {
×
63
    // This should ideally match or be related to DhtConfig.network_discovery.max_seed_peer_sync_count
64
    // For now, a sensible default. This will be overridden by DhtEvent if DhtNetworkDiscoveryRoundInfo provides
65
    // total_rounds.
66
    5
×
67
}
×
68

69
fn max_reorg_depth_allowed() -> usize {
×
70
    10000
×
71
}
×
72

73
impl Default for BlockchainSyncConfig {
74
    fn default() -> Self {
×
75
        Self {
×
76
            initial_max_sync_latency: Duration::from_secs(240), // Syncing many full blocks over tor require this
×
77
            max_latency_increase: Duration::from_secs(10),      // Syncing many full blocks over tor require this
×
78
            ban_period: Duration::from_secs(60 * 60 * 2),       // 2 hours
×
79
            short_ban_period: Duration::from_secs(240),         // 4 mins
×
80
            forced_sync_peers: Default::default(),
×
81
            validation_concurrency: 6,
×
82
            rpc_deadline: Duration::from_secs(240), // Syncing many full blocks over tor require this
×
83
            num_initial_sync_rounds_seed_bootstrap: default_num_initial_sync_rounds_seed_bootstrap(),
×
84
            max_reorg_depth_allowed: max_reorg_depth_allowed(),
×
85
        }
×
86
    }
×
87
}
88

89
impl BlockchainSyncConfig {
90
    // Add an accessor if one doesn't exist for the new field
91
    pub fn num_initial_sync_rounds_seed_bootstrap(&self) -> usize {
×
92
        self.num_initial_sync_rounds_seed_bootstrap
×
93
    }
×
94
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc