snarkos_node_bft/helpers/
mod.rs

1// Copyright 2024 Aleo Network Foundation
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
16pub mod cache;
17pub use cache::*;
18
19pub mod channels;
20pub use channels::*;
21
22pub mod dag;
23pub use dag::*;
24
25pub mod partition;
26pub use partition::*;
27
28pub mod pending;
29pub use pending::*;
30
31pub mod proposal;
32pub use proposal::*;
33
34pub mod proposal_cache;
35pub use proposal_cache::*;
36
37pub mod ready;
38pub use ready::*;
39
40pub mod resolver;
41pub use resolver::*;
42
43pub mod signed_proposals;
44pub use signed_proposals::*;
45
46pub mod storage;
47pub use storage::*;
48
49pub mod timestamp;
50pub use timestamp::*;
51
52/// Formats an ID into a truncated identifier (for logging purposes).
53pub fn fmt_id(id: impl ToString) -> String {
54    let id = id.to_string();
55    let mut formatted_id = id.chars().take(16).collect::<String>();
56    if id.chars().count() > 16 {
57        formatted_id.push_str("..");
58    }
59    formatted_id
60}