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

tari-project / tari / 16990089413

15 Aug 2025 12:36PM UTC coverage: 54.497% (+0.06%) from 54.441%
16990089413

push

github

web-flow
chore: cleanup indexes (#7411)

Description
---
Forces clean indexs

970 of 2919 new or added lines in 369 files covered. (33.23%)

60 existing lines in 33 files now uncovered.

76698 of 140739 relevant lines covered (54.5%)

193749.86 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/ban.rs
1
//  Copyright 2023, 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 log::*;
26
use tari_comms::{connectivity::ConnectivityRequester, peer_manager::NodeId};
27

28
use crate::base_node::BlockchainSyncConfig;
29

30
const LOG_TARGET: &str = "c::bn::sync";
31

32
// Sync peers are banned if there exists a ban reason for the error and the peer is not on the allow list for sync.
33

34
pub struct PeerBanManager {
35
    config: BlockchainSyncConfig,
36
    connectivity: ConnectivityRequester,
37
}
38

39
impl PeerBanManager {
40
    pub fn new(config: BlockchainSyncConfig, connectivity: ConnectivityRequester) -> Self {
×
41
        Self { config, connectivity }
×
42
    }
×
43

44
    pub async fn ban_peer_if_required(&mut self, node_id: &NodeId, ban_reason: String, ban_duration: Duration) {
×
45
        if self.config.forced_sync_peers.contains(node_id) {
×
46
            debug!(
×
47
                target: LOG_TARGET,
×
NEW
48
                "Not banning peer that is on the allow list for sync. Ban reason = {ban_reason}"
×
49
            );
50
            return;
×
51
        }
×
NEW
52
        debug!(target: LOG_TARGET, "Sync peer {node_id} removed from the sync peer list because {ban_reason}");
×
53

54
        match self
×
55
            .connectivity
×
56
            .ban_peer_until(node_id.clone(), ban_duration, ban_reason.clone())
×
57
            .await
×
58
        {
59
            Ok(_) => {
NEW
60
                warn!(target: LOG_TARGET, "Banned sync peer {node_id} for {ban_duration:?} because {ban_reason}")
×
61
            },
NEW
62
            Err(err) => error!(target: LOG_TARGET, "Failed to ban sync peer {node_id}: {err}"),
×
63
        }
64
    }
×
65
}
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