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

tari-project / tari / 17033178607

18 Aug 2025 06:45AM UTC coverage: 54.49% (-0.007%) from 54.497%
17033178607

push

github

stringhandler
Merge branch 'development' of github.com:tari-project/tari into odev

971 of 2923 new or added lines in 369 files covered. (33.22%)

5804 existing lines in 173 files now uncovered.

76688 of 140739 relevant lines covered (54.49%)

193850.18 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::{BlockHash, CompressedCommitment, CompressedPublicKey, FixedHash, HashOutput, PrivateKey, Signature},
32
};
33
use tari_utilities::hex::Hex;
34

35
use crate::{blocks::NewBlockTemplate, chain_storage::MmrTree, proof_of_work::PowAlgorithm};
36

37
/// A container for the parameters required for a FetchMmrState request.
38
#[derive(Debug, Serialize, Deserialize)]
×
39
pub struct MmrStateRequest {
40
    pub tree: MmrTree,
41
    pub index: u64,
42
    pub count: u64,
43
}
44

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

93
#[derive(Debug, Serialize, Deserialize)]
×
94
pub struct GetNewBlockTemplateRequest {
95
    pub algo: PowAlgorithm,
96
    pub max_weight: u64,
97
}
98

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