snarkos_node_tcp/helpers/
mod.rs

1// Copyright (c) 2019-2025 Provable Inc.
2// This file is part of the snarkOS library.
3
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at:
7
8// http://www.apache.org/licenses/LICENSE-2.0
9
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15
16mod config;
17pub use config::Config;
18
19mod banned_peers;
20pub use banned_peers::BannedPeers;
21
22pub mod connections;
23pub use connections::{Connection, ConnectionSide};
24
25mod known_peers;
26pub use known_peers::KnownPeers;
27
28mod stats;
29pub use stats::Stats;
30
31use tracing::{Span, debug_span, error_span, info_span, trace_span, warn_span};
32
33/// Creates the Tcp's tracing span based on its name.
34pub fn create_span(tcp_name: &str) -> Span {
35    let mut span = trace_span!("tcp", name = tcp_name);
36    if span.is_disabled() {
37        span = debug_span!("tcp", name = tcp_name);
38    }
39    if span.is_disabled() {
40        span = info_span!("tcp", name = tcp_name);
41    }
42    if span.is_disabled() {
43        span = warn_span!("tcp", name = tcp_name);
44    }
45    if span.is_disabled() {
46        span = error_span!("tcp", name = tcp_name);
47    }
48    span
49}