• 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_request.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::{Display, Error, Formatter},
25
    ops::RangeInclusive,
26
};
27

28
use serde::{Deserialize, Serialize};
29
use tari_common_types::{
30
    epoch::VnEpoch,
31
    types::{
32
        BlockHash,
33
        CompressedCommitment,
34
        CompressedPublicKey,
35
        CompressedSignature,
36
        FixedHash,
37
        HashOutput,
38
        PrivateKey,
39
    },
40
};
41
use tari_node_components::blocks::NewBlockTemplate;
42
use tari_transaction_components::tari_proof_of_work::PowAlgorithm;
43
use tari_utilities::hex::Hex;
44

45
use crate::chain_storage::MmrTree;
46
/// A container for the parameters required for a FetchMmrState request.
47
#[derive(Debug, Serialize, Deserialize)]
×
48
pub struct MmrStateRequest {
49
    pub tree: MmrTree,
50
    pub index: u64,
51
    pub count: u64,
52
}
53

54
/// API Request enum
55
#[derive(Debug, Serialize, Deserialize)]
×
56
pub enum NodeCommsRequest {
57
    GetChainMetadata,
58
    GetTargetDifficultyNextBlock(PowAlgorithm),
59
    FetchHeaders(RangeInclusive<u64>),
60
    FetchHeadersByHashes(Vec<HashOutput>),
61
    FetchMatchingUtxos(Vec<HashOutput>),
62
    FetchMatchingBlocks {
63
        range: RangeInclusive<u64>,
64
        compact: bool,
65
    },
66
    FetchBlocksByKernelExcessSigs(Vec<CompressedSignature>),
67
    FetchBlocksByUtxos(Vec<CompressedCommitment>),
68
    GetHeaderByHash(HashOutput),
69
    GetBlockByHash(HashOutput),
70
    GetNewBlockTemplate(GetNewBlockTemplateRequest),
71
    GetNewBlock(NewBlockTemplate),
72
    GetBlockFromAllChains(HashOutput),
73
    FetchKernelByExcessSig(CompressedSignature),
74
    FetchMempoolTransactionsByExcessSigs {
75
        excess_sigs: Vec<PrivateKey>,
76
    },
77
    FetchTemplateRegistrations {
78
        start_height: u64,
79
        end_height: u64,
80
    },
81
    FetchUnspentUtxosInBlock {
82
        block_hash: BlockHash,
83
    },
84
    FetchMinedInfoByPayRef(FixedHash),
85
    FetchMinedInfoByOutputHash(HashOutput),
86
    FetchOutputMinedInfo(HashOutput),
87
    CheckOutputSpentStatus(HashOutput),
88
    FetchValidatorNodesKeys {
89
        height: u64,
90
        validator_network: Option<CompressedPublicKey>,
91
    },
92
    FetchValidatorNodeChanges {
93
        epoch: VnEpoch,
94
        sidechain_id: Option<CompressedPublicKey>,
95
    },
96
    GetValidatorNode {
97
        sidechain_id: Option<CompressedPublicKey>,
98
        public_key: CompressedPublicKey,
99
    },
100
}
101

102
#[derive(Debug, Serialize, Deserialize)]
×
103
pub struct GetNewBlockTemplateRequest {
104
    pub algo: PowAlgorithm,
105
    pub max_weight: u64,
106
}
107

108
impl Display for NodeCommsRequest {
109
    fn fmt(&self, f: &mut Formatter) -> Result<(), Error> {
×
110
        #[allow(clippy::enum_glob_use)]
111
        use NodeCommsRequest::*;
112
        match self {
×
113
            GetChainMetadata => write!(f, "GetChainMetadata"),
×
114
            GetTargetDifficultyNextBlock(algo) => write!(f, "GetTargetDifficultyNextBlock ({algo:?})"),
×
115
            FetchHeaders(range) => {
×
116
                write!(f, "FetchHeaders ({range:?})")
×
117
            },
118
            FetchHeadersByHashes(v) => write!(f, "FetchHeadersByHashes (n={})", v.len()),
×
119
            FetchMatchingUtxos(v) => write!(f, "FetchMatchingUtxos (n={})", v.len()),
×
120
            FetchMatchingBlocks { range, compact } => {
×
121
                write!(f, "FetchMatchingBlocks ({range:?}, {compact})")
×
122
            },
123
            FetchBlocksByKernelExcessSigs(v) => write!(f, "FetchBlocksByKernelExcessSigs (n={})", v.len()),
×
124
            FetchBlocksByUtxos(v) => write!(f, "FetchBlocksByUtxos (n={})", v.len()),
×
125
            GetHeaderByHash(v) => write!(f, "GetHeaderByHash({v})"),
×
126
            GetBlockByHash(v) => write!(f, "GetBlockByHash({v})"),
×
127
            GetNewBlockTemplate(v) => write!(f, "GetNewBlockTemplate ({}) with weight {}", v.algo, v.max_weight),
×
128
            GetNewBlock(b) => write!(f, "GetNewBlock (Block Height={})", b.header.height),
×
129
            GetBlockFromAllChains(v) => write!(f, "GetBlockFromAllChains({v})"),
×
130
            FetchKernelByExcessSig(s) => write!(
×
131
                f,
×
132
                "FetchKernelByExcessSig (signature=({}, {}))",
×
133
                s.get_compressed_public_nonce().to_hex(),
×
134
                s.get_signature().to_hex()
×
135
            ),
×
136
            FetchMempoolTransactionsByExcessSigs { .. } => {
137
                write!(f, "FetchMempoolTransactionsByExcessSigs")
×
138
            },
139
            FetchValidatorNodesKeys {
140
                height,
×
141
                validator_network,
×
142
            } => {
×
143
                write!(
×
144
                    f,
×
145
                    "FetchValidatorNodesKeys ({}, {})",
×
146
                    height,
×
147
                    validator_network
×
148
                        .as_ref()
×
149
                        .map(|n| n.to_hex())
×
150
                        .unwrap_or_else(|| "None".to_string())
×
151
                )
×
152
            },
153
            GetValidatorNode {
154
                sidechain_id,
×
155
                public_key,
×
156
            } => {
×
157
                write!(f, "GetValidatorNode ({sidechain_id:?}), public key ({public_key:?})")
×
158
            },
159
            FetchTemplateRegistrations {
160
                start_height: start,
×
161
                end_height: end,
×
162
            } => {
×
163
                write!(f, "FetchTemplateRegistrations ({start}..={end})")
×
164
            },
165
            FetchUnspentUtxosInBlock { block_hash } => {
×
166
                write!(f, "FetchUnspentUtxosInBlock ({block_hash})")
×
167
            },
168
            FetchMinedInfoByPayRef(payref) => {
×
169
                write!(f, "FetchMinedInfoByPayRef ({payref})")
×
170
            },
171
            FetchMinedInfoByOutputHash(payref) => {
×
172
                write!(f, "FetchMinedInfoByOutputHash ({payref})")
×
173
            },
174
            FetchOutputMinedInfo(output_hash) => {
×
175
                write!(f, "FetchOutputMinedInfo ({output_hash})")
×
176
            },
177
            CheckOutputSpentStatus(output_hash) => {
×
178
                write!(f, "CheckOutputSpentStatus ({output_hash})")
×
179
            },
180
            FetchValidatorNodeChanges { epoch, sidechain_id } => {
×
181
                write!(
×
182
                    f,
×
183
                    "FetchValidatorNodeChanges (Side chain ID:{sidechain_id:?}), Epoch: {epoch}"
×
184
                )
×
185
            },
186
        }
187
    }
×
188
}
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