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

tari-project / tari / 16123384529

07 Jul 2025 05:11PM UTC coverage: 64.327% (-7.6%) from 71.89%
16123384529

push

github

web-flow
chore: new release v4.9.0-pre.0 (#7289)

Description
---
new release esmeralda

77151 of 119935 relevant lines covered (64.33%)

227108.34 hits per line

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

0.0
/base_layer/core/src/base_node/proto/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::convert::{TryFrom, TryInto};
24

25
use tari_common_types::types::PrivateKey;
26
use tari_utilities::ByteArray;
27

28
use crate::{
29
    base_node::comms_interface::NodeCommsRequest,
30
    proto::{base_node as proto, base_node::base_node_service_request::Request as ProtoNodeCommsRequest},
31
};
32

33
//---------------------------------- BaseNodeRequest --------------------------------------------//
34
impl TryInto<NodeCommsRequest> for ProtoNodeCommsRequest {
35
    type Error = String;
36

37
    fn try_into(self) -> Result<NodeCommsRequest, Self::Error> {
×
38
        use ProtoNodeCommsRequest::{FetchMempoolTransactionsByExcessSigs, GetBlockFromAllChains};
39
        let request = match self {
×
40
            GetBlockFromAllChains(req) => {
×
41
                NodeCommsRequest::GetBlockFromAllChains(req.hash.try_into().map_err(|_| "Malformed hash".to_string())?)
×
42
            },
43
            FetchMempoolTransactionsByExcessSigs(excess_sigs) => {
×
44
                let excess_sigs = excess_sigs
×
45
                    .excess_sigs
×
46
                    .into_iter()
×
47
                    .map(|bytes| {
×
48
                        PrivateKey::from_canonical_bytes(&bytes).map_err(|_| "Malformed excess sig".to_string())
×
49
                    })
×
50
                    .collect::<Result<_, _>>()?;
×
51

52
                NodeCommsRequest::FetchMempoolTransactionsByExcessSigs { excess_sigs }
×
53
            },
54
        };
55
        Ok(request)
×
56
    }
×
57
}
58

59
impl TryFrom<NodeCommsRequest> for ProtoNodeCommsRequest {
60
    type Error = String;
61

62
    fn try_from(request: NodeCommsRequest) -> Result<Self, Self::Error> {
×
63
        use NodeCommsRequest::{FetchMempoolTransactionsByExcessSigs, GetBlockFromAllChains};
64
        match request {
×
65
            GetBlockFromAllChains(hash) => Ok(ProtoNodeCommsRequest::GetBlockFromAllChains(
×
66
                proto::GetBlockFromAllChainsRequest { hash: hash.to_vec() },
×
67
            )),
×
68
            FetchMempoolTransactionsByExcessSigs { excess_sigs } => Ok(
×
69
                ProtoNodeCommsRequest::FetchMempoolTransactionsByExcessSigs(proto::ExcessSigs {
×
70
                    excess_sigs: excess_sigs.into_iter().map(|sig| sig.to_vec()).collect(),
×
71
                }),
×
72
            ),
×
73
            e => Err(format!("{} request is not supported", e)),
×
74
        }
75
    }
×
76
}
77

78
//---------------------------------- Wrappers --------------------------------------------//
79

80
impl From<Vec<u64>> for proto::BlockHeights {
81
    fn from(heights: Vec<u64>) -> Self {
×
82
        Self { heights }
×
83
    }
×
84
}
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