Skip to main content

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::{
15    CanonicalTransaction, LedgerTransaction, SpendingId, SpentTransaction,
16};
17
18mod faults;
19pub use faults::{Fault, InvalidFault, Slash, SlashType};
20
21mod attestation;
22use std::io::{self, Read, Write};
23
24pub use attestation::{
25    Attestation, IterationInfo, IterationsInfo, Signature, StepVotes,
26};
27#[cfg(any(feature = "faker", test))]
28use fake::{Dummy, Fake, Faker};
29use sha3::Digest;
30
31use crate::Serializable;
32use crate::bls::PublicKeyBytes;
33
34/// Encode a byte array into a shortened HEX representation.
35pub fn to_str(bytes: &[u8]) -> String {
36    const OFFSET: usize = 16;
37    let hex = hex::encode(bytes);
38    if bytes.len() <= OFFSET {
39        return hex;
40    }
41
42    let len = hex.len();
43
44    let first = &hex[0..OFFSET];
45    let last = &hex[len - OFFSET..];
46
47    format!("{first}...{last}")
48}
49
50#[cfg(any(feature = "faker", test))]
51pub mod faker {
52    pub use super::transaction::faker::gen_dummy_tx;
53}