dusk_node_data/
ledger.rs

1// This Source Code Form is subject to the terms of the Mozilla Public
2// License, v. 2.0. If a copy of the MPL was not distributed with this
3// file, You can obtain one at http://mozilla.org/MPL/2.0/.
4//
5// Copyright (c) DUSK NETWORK. All rights reserved.
6
7mod header;
8pub use header::{Header, Seed};
9
10mod block;
11pub use block::*;
12
13mod transaction;
14pub use transaction::{SpendingId, SpentTransaction, Transaction};
15
16mod faults;
17pub use faults::{Fault, InvalidFault, Slash, SlashType};
18
19mod attestation;
20pub use attestation::{
21    Attestation, IterationInfo, IterationsInfo, Signature, StepVotes,
22};
23
24use std::io::{self, Read, Write};
25
26#[cfg(any(feature = "faker", test))]
27use fake::{Dummy, Fake, Faker};
28use sha3::Digest;
29
30use crate::bls::PublicKeyBytes;
31use crate::Serializable;
32
33/// Encode a byte array into a shortened HEX representation.
34pub fn to_str(bytes: &[u8]) -> String {
35    const OFFSET: usize = 16;
36    let hex = hex::encode(bytes);
37    if bytes.len() <= OFFSET {
38        return hex;
39    }
40
41    let len = hex.len();
42
43    let first = &hex[0..OFFSET];
44    let last = &hex[len - OFFSET..];
45
46    format!("{first}...{last}")
47}
48
49#[cfg(any(feature = "faker", test))]
50pub mod faker {
51    pub use super::transaction::faker::gen_dummy_tx;
52}