MCPcopy Create free account
hub / github.com/0xMiden/node / decode

Method decode

crates/rpc/src/server/api/submit_auth_tx_batch.rs:16–41  ·  view source on GitHub ↗
(
        request: proto::sequencer::AuthenticatedTransactionBatch,
    )

Source from the content-addressed store, hash-verified

14 type Output = proto::blockchain::BlockNumber;
15
16 fn decode(
17 request: proto::sequencer::AuthenticatedTransactionBatch,
18 ) -> tonic::Result<Self::Input> {
19 let batch = ProposedBatch::read_from_bytes(&request.proposed_batch).map_err(|err| {
20 Status::invalid_argument(err.as_report_context("invalid proposed_batch"))
21 })?;
22
23 if batch.transactions().len() != request.auth_inputs.len() {
24 return Err(Status::invalid_argument(format!(
25 "Number of inputs {} does not match number of transactions {} in batch",
26 request.auth_inputs.len(),
27 batch.transactions().len()
28 )));
29 }
30
31 let inputs = request
32 .auth_inputs
33 .into_iter()
34 .map(TransactionInputs::try_from)
35 .collect::<Result<Vec<_>, _>>()
36 .map_err(|err| {
37 Status::invalid_argument(err.as_report_context("invalid auth_inputs"))
38 })?;
39
40 Ok((batch, inputs))
41 }
42
43 fn encode(output: Self::Output) -> tonic::Result<proto::blockchain::BlockNumber> {
44 Ok(output)

Callers

nothing calls this directly

Calls 4

as_report_contextMethod · 0.80
transactionsMethod · 0.80
map_errMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected