miden_objects/block/
block_inputs.rs1use alloc::collections::BTreeMap;
2
3use crate::{
4 account::AccountId,
5 block::{AccountWitness, BlockHeader, NullifierWitness},
6 note::{NoteId, NoteInclusionProof, Nullifier},
7 transaction::PartialBlockchain,
8};
9
10#[derive(Clone, Debug)]
15pub struct BlockInputs {
16 prev_block_header: BlockHeader,
18
19 partial_blockchain: PartialBlockchain,
23
24 account_witnesses: BTreeMap<AccountId, AccountWitness>,
26
27 nullifier_witnesses: BTreeMap<Nullifier, NullifierWitness>,
29
30 unauthenticated_note_proofs: BTreeMap<NoteId, NoteInclusionProof>,
33}
34
35impl BlockInputs {
36 pub fn new(
38 prev_block_header: BlockHeader,
39 partial_blockchain: PartialBlockchain,
40 account_witnesses: BTreeMap<AccountId, AccountWitness>,
41 nullifier_witnesses: BTreeMap<Nullifier, NullifierWitness>,
42 unauthenticated_note_proofs: BTreeMap<NoteId, NoteInclusionProof>,
43 ) -> Self {
44 Self {
45 prev_block_header,
46 partial_blockchain,
47 account_witnesses,
48 nullifier_witnesses,
49 unauthenticated_note_proofs,
50 }
51 }
52
53 pub fn prev_block_header(&self) -> &BlockHeader {
55 &self.prev_block_header
56 }
57
58 pub fn partial_blockchain(&self) -> &PartialBlockchain {
60 &self.partial_blockchain
61 }
62
63 pub fn account_witnesses(&self) -> &BTreeMap<AccountId, AccountWitness> {
65 &self.account_witnesses
66 }
67
68 pub fn nullifier_witnesses(&self) -> &BTreeMap<Nullifier, NullifierWitness> {
70 &self.nullifier_witnesses
71 }
72
73 pub fn unauthenticated_note_proofs(&self) -> &BTreeMap<NoteId, NoteInclusionProof> {
75 &self.unauthenticated_note_proofs
76 }
77
78 #[allow(clippy::type_complexity)]
80 pub fn into_parts(
81 self,
82 ) -> (
83 BlockHeader,
84 PartialBlockchain,
85 BTreeMap<AccountId, AccountWitness>,
86 BTreeMap<Nullifier, NullifierWitness>,
87 BTreeMap<NoteId, NoteInclusionProof>,
88 ) {
89 (
90 self.prev_block_header,
91 self.partial_blockchain,
92 self.account_witnesses,
93 self.nullifier_witnesses,
94 self.unauthenticated_note_proofs,
95 )
96 }
97
98 #[cfg(any(feature = "testing", test))]
105 pub fn partial_blockchain_mut(&mut self) -> &mut PartialBlockchain {
106 &mut self.partial_blockchain
107 }
108
109 #[cfg(any(feature = "testing", test))]
113 pub fn unauthenticated_note_proofs_mut(&mut self) -> &mut BTreeMap<NoteId, NoteInclusionProof> {
114 &mut self.unauthenticated_note_proofs
115 }
116
117 #[cfg(any(feature = "testing", test))]
121 pub fn nullifier_witnesses_mut(&mut self) -> &mut BTreeMap<Nullifier, NullifierWitness> {
122 &mut self.nullifier_witnesses
123 }
124
125 #[cfg(any(feature = "testing", test))]
129 pub fn account_witnesses_mut(&mut self) -> &mut BTreeMap<AccountId, AccountWitness> {
130 &mut self.account_witnesses
131 }
132}