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

tari-project / tari / 16123384529

07 Jul 2025 05:11PM UTC coverage: 64.327% (-7.6%) from 71.89%
16123384529

push

github

web-flow
chore: new release v4.9.0-pre.0 (#7289)

Description
---
new release esmeralda

77151 of 119935 relevant lines covered (64.33%)

227108.34 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
}
58

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

66
impl Default for BlockchainSyncConfig {
67
    fn default() -> Self {
×
68
        Self {
×
69
            initial_max_sync_latency: Duration::from_secs(240), // Syncing many full blocks over tor require this
×
70
            max_latency_increase: Duration::from_secs(10),      // Syncing many full blocks over tor require this
×
71
            ban_period: Duration::from_secs(60 * 60 * 2),       // 2 hours
×
72
            short_ban_period: Duration::from_secs(240),         // 4 mins
×
73
            forced_sync_peers: Default::default(),
×
74
            validation_concurrency: 6,
×
75
            rpc_deadline: Duration::from_secs(240), // Syncing many full blocks over tor require this
×
76
            num_initial_sync_rounds_seed_bootstrap: default_num_initial_sync_rounds_seed_bootstrap(),
×
77
        }
×
78
    }
×
79
}
80

81
impl BlockchainSyncConfig {
82
    // Add an accessor if one doesn't exist for the new field
83
    pub fn num_initial_sync_rounds_seed_bootstrap(&self) -> usize {
×
84
        self.num_initial_sync_rounds_seed_bootstrap
×
85
    }
×
86
}
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