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

tari-project / tari / 17275382059

27 Aug 2025 06:28PM UTC coverage: 60.14% (-0.1%) from 60.274%
17275382059

push

github

web-flow
chore: new release v5.0.0-pre.8 (#7446)

Description
---
new release

71505 of 118897 relevant lines covered (60.14%)

536444.51 hits per line

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

0.0
/base_layer/core/src/base_node/comms_interface/comms_response.rs
1
// Copyright 2019. 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::{
24
    fmt::{self, Display, Formatter},
25
    sync::Arc,
26
};
27

28
use tari_common_types::{
29
    chain_metadata::ChainMetadata,
30
    epoch::VnEpoch,
31
    types::{CompressedPublicKey, FixedHash, HashOutput, PrivateKey},
32
};
33
use tari_node_components::blocks::{Block, NewBlockTemplate};
34
use tari_transaction_components::{
35
    tari_proof_of_work::Difficulty,
36
    transaction_components::{Transaction, TransactionKernel, TransactionOutput, ValidatorNodeRegistration},
37
    MicroMinotari,
38
};
39

40
use crate::{
41
    blocks::{ChainHeader, HistoricalBlock},
42
    chain_storage::{
43
        InputMinedInfo,
44
        MinedInfo,
45
        OutputMinedInfo,
46
        TemplateRegistrationEntry,
47
        ValidatorNodeRegistrationInfo,
48
    },
49
};
50
/// API Response enum
51
#[allow(clippy::large_enum_variant)]
52
#[derive(Debug, Clone)]
53
pub enum NodeCommsResponse {
54
    ChainMetadata(ChainMetadata),
55
    TransactionKernels(Vec<TransactionKernel>),
56
    BlockHeaders(Vec<ChainHeader>),
57
    BlockHeader(Option<ChainHeader>),
58
    Block(Box<Option<Block>>),
59
    TransactionOutputs(Vec<TransactionOutput>),
60
    HistoricalBlocks(Vec<HistoricalBlock>),
61
    HistoricalBlock(Box<Option<HistoricalBlock>>),
62
    NewBlockTemplate(NewBlockTemplate),
63
    NewBlock {
64
        success: bool,
65
        error: Option<String>,
66
        block: Option<Block>,
67
    },
68
    TargetDifficulty(Difficulty),
69
    MmrNodes(Vec<HashOutput>, Vec<u8>),
70
    FetchMempoolTransactionsByExcessSigsResponse(FetchMempoolTransactionsResponse),
71
    FetchValidatorNodesKeysResponse(Vec<ValidatorNodeRegistrationInfo>),
72
    FetchValidatorNodeChangesResponse(Vec<ValidatorNodeChange>),
73
    GetValidatorNode(Option<ValidatorNodeRegistrationInfo>),
74
    FetchTemplateRegistrationsResponse(Vec<TemplateRegistrationEntry>),
75
    OutputMinedInfo(Option<OutputMinedInfo>),
76
    MinedInfo(MinedInfo),
77
    InputMinedInfo(Option<InputMinedInfo>),
78
    PayRef(Option<FixedHash>),
79
}
80

81
impl Display for NodeCommsResponse {
82
    fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
×
83
        #[allow(clippy::enum_glob_use)]
84
        use NodeCommsResponse::*;
85
        match self {
×
86
            ChainMetadata(_) => write!(f, "ChainMetadata"),
×
87
            TransactionKernels(_) => write!(f, "TransactionKernel"),
×
88
            BlockHeaders(_) => write!(f, "BlockHeaders"),
×
89
            BlockHeader(_) => write!(f, "BlockHeader"),
×
90
            Block(_) => write!(f, "Block"),
×
91
            HistoricalBlock(_) => write!(f, "HistoricalBlock"),
×
92
            TransactionOutputs(_) => write!(f, "TransactionOutputs"),
×
93
            HistoricalBlocks(_) => write!(f, "HistoricalBlocks"),
×
94
            NewBlockTemplate(_) => write!(f, "NewBlockTemplate"),
×
95
            NewBlock {
96
                success,
×
97
                error,
×
98
                block: _,
×
99
            } => write!(
×
100
                f,
×
101
                "NewBlock({},{},...)",
×
102
                success,
×
103
                error.as_ref().unwrap_or(&"Unspecified".to_string())
×
104
            ),
×
105
            TargetDifficulty(_) => write!(f, "TargetDifficulty"),
×
106
            MmrNodes(_, _) => write!(f, "MmrNodes"),
×
107
            FetchMempoolTransactionsByExcessSigsResponse(resp) => write!(
×
108
                f,
×
109
                "FetchMempoolTransactionsByExcessSigsResponse({} transaction(s), {} not found)",
×
110
                resp.transactions.len(),
×
111
                resp.not_found.len()
×
112
            ),
×
113
            FetchValidatorNodesKeysResponse(_) => write!(f, "FetchValidatorNodesKeysResponse"),
×
114
            GetValidatorNode(_) => write!(f, "GetValidatorNode"),
×
115
            FetchTemplateRegistrationsResponse(_) => write!(f, "FetchTemplateRegistrationsResponse"),
×
116
            OutputMinedInfo(_) => write!(f, "OutputMinedInfo"),
×
117
            MinedInfo(_) => write!(f, "MinedInfo"),
×
118
            InputMinedInfo(_) => write!(f, "InputMinedInfo"),
×
119
            PayRef(_) => write!(f, "PayRef"),
×
120
            FetchValidatorNodeChangesResponse(_) => write!(f, "FetchValidatorNodeChangesResponse"),
×
121
        }
122
    }
×
123
}
124

125
/// Container struct for mempool transaction responses
126
#[derive(Debug, Clone)]
127
pub struct FetchMempoolTransactionsResponse {
128
    pub transactions: Vec<Arc<Transaction>>,
129
    pub not_found: Vec<PrivateKey>,
130
}
131

132
/// Represents a validator node state change
133
#[derive(Debug, Clone)]
134
pub enum ValidatorNodeChange {
135
    Add {
136
        registration: Box<ValidatorNodeRegistration>,
137
        activation_epoch: VnEpoch,
138
        minimum_value_promise: MicroMinotari,
139
        shard_key: [u8; 32],
140
    },
141
    Remove {
142
        public_key: CompressedPublicKey,
143
    },
144
}
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