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

tari-project / tari / 15443674054

04 Jun 2025 01:30PM UTC coverage: 72.396% (+0.07%) from 72.329%
15443674054

push

github

web-flow
fix: remove code for deleting stale peers (#7184)

This code is no longer needed since the switch to sqlite

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **Refactor**
- Removed the automatic deletion of stale peers from the connectivity
and peer management processes. The system will no longer periodically
delete inactive or stale peers from the database.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

2 of 2 new or added lines in 1 file covered. (100.0%)

625 existing lines in 43 files now uncovered.

81294 of 112290 relevant lines covered (72.4%)

243381.89 hits per line

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

16.67
/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 {
12✔
41
        Self { config, connectivity }
12✔
42
    }
12✔
43

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

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