miden_objects/block/
block_inputs.rs1use alloc::collections::BTreeMap;
2
3use crate::account::AccountId;
4use crate::block::{AccountWitness, BlockHeader, NullifierWitness};
5use crate::note::{NoteId, NoteInclusionProof, Nullifier};
6use crate::transaction::PartialBlockchain;
7
8#[derive(Clone, Debug)]
13pub struct BlockInputs {
14 prev_block_header: BlockHeader,
16
17 partial_blockchain: PartialBlockchain,
21
22 account_witnesses: BTreeMap<AccountId, AccountWitness>,
24
25 nullifier_witnesses: BTreeMap<Nullifier, NullifierWitness>,
27
28 unauthenticated_note_proofs: BTreeMap<NoteId, NoteInclusionProof>,
31}
32
33impl BlockInputs {
34 pub fn new(
36 prev_block_header: BlockHeader,
37 partial_blockchain: PartialBlockchain,
38 account_witnesses: BTreeMap<AccountId, AccountWitness>,
39 nullifier_witnesses: BTreeMap<Nullifier, NullifierWitness>,
40 unauthenticated_note_proofs: BTreeMap<NoteId, NoteInclusionProof>,
41 ) -> Self {
42 Self {
43 prev_block_header,
44 partial_blockchain,
45 account_witnesses,
46 nullifier_witnesses,
47 unauthenticated_note_proofs,
48 }
49 }
50
51 pub fn prev_block_header(&self) -> &BlockHeader {
53 &self.prev_block_header
54 }
55
56 pub fn partial_blockchain(&self) -> &PartialBlockchain {
58 &self.partial_blockchain
59 }
60
61 pub fn account_witnesses(&self) -> &BTreeMap<AccountId, AccountWitness> {
63 &self.account_witnesses
64 }
65
66 pub fn nullifier_witnesses(&self) -> &BTreeMap<Nullifier, NullifierWitness> {
68 &self.nullifier_witnesses
69 }
70
71 pub fn unauthenticated_note_proofs(&self) -> &BTreeMap<NoteId, NoteInclusionProof> {
73 &self.unauthenticated_note_proofs
74 }
75
76 #[allow(clippy::type_complexity)]
78 pub fn into_parts(
79 self,
80 ) -> (
81 BlockHeader,
82 PartialBlockchain,
83 BTreeMap<AccountId, AccountWitness>,
84 BTreeMap<Nullifier, NullifierWitness>,
85 BTreeMap<NoteId, NoteInclusionProof>,
86 ) {
87 (
88 self.prev_block_header,
89 self.partial_blockchain,
90 self.account_witnesses,
91 self.nullifier_witnesses,
92 self.unauthenticated_note_proofs,
93 )
94 }
95
96 #[cfg(any(feature = "testing", test))]
103 pub fn partial_blockchain_mut(&mut self) -> &mut PartialBlockchain {
104 &mut self.partial_blockchain
105 }
106
107 #[cfg(any(feature = "testing", test))]
111 pub fn unauthenticated_note_proofs_mut(&mut self) -> &mut BTreeMap<NoteId, NoteInclusionProof> {
112 &mut self.unauthenticated_note_proofs
113 }
114
115 #[cfg(any(feature = "testing", test))]
119 pub fn nullifier_witnesses_mut(&mut self) -> &mut BTreeMap<Nullifier, NullifierWitness> {
120 &mut self.nullifier_witnesses
121 }
122
123 #[cfg(any(feature = "testing", test))]
127 pub fn account_witnesses_mut(&mut self) -> &mut BTreeMap<AccountId, AccountWitness> {
128 &mut self.account_witnesses
129 }
130}