miden_client/transaction/
store_update.rs1use alloc::vec::Vec;
2
3use miden_protocol::block::BlockNumber;
4use miden_protocol::note::{NoteDetails, NoteTag};
5use miden_protocol::transaction::ExecutedTransaction;
6use miden_tx::utils::serde::{
7 ByteReader,
8 ByteWriter,
9 Deserializable,
10 DeserializationError,
11 Serializable,
12};
13
14use crate::note::NoteUpdateTracker;
15use crate::sync::NoteTagRecord;
16
17#[derive(Debug, Clone)]
23pub struct TransactionStoreUpdate {
24 executed_transaction: ExecutedTransaction,
26 submission_height: BlockNumber,
28 future_notes: Vec<(NoteDetails, NoteTag)>,
30 note_updates: NoteUpdateTracker,
32 new_tags: Vec<NoteTagRecord>,
34}
35
36impl TransactionStoreUpdate {
37 pub fn new(
48 executed_transaction: ExecutedTransaction,
49 submission_height: BlockNumber,
50 note_updates: NoteUpdateTracker,
51 future_notes: Vec<(NoteDetails, NoteTag)>,
52 new_tags: Vec<NoteTagRecord>,
53 ) -> Self {
54 Self {
55 executed_transaction,
56 submission_height,
57 future_notes,
58 note_updates,
59 new_tags,
60 }
61 }
62 pub fn executed_transaction(&self) -> &ExecutedTransaction {
64 &self.executed_transaction
65 }
66
67 pub fn submission_height(&self) -> BlockNumber {
69 self.submission_height
70 }
71
72 pub fn future_notes(&self) -> &[(NoteDetails, NoteTag)] {
74 &self.future_notes
75 }
76
77 pub fn note_updates(&self) -> &NoteUpdateTracker {
79 &self.note_updates
80 }
81
82 pub fn new_tags(&self) -> &[NoteTagRecord] {
84 &self.new_tags
85 }
86}
87
88impl Serializable for TransactionStoreUpdate {
89 fn write_into<W: ByteWriter>(&self, target: &mut W) {
90 self.executed_transaction.write_into(target);
91 self.submission_height.write_into(target);
92 self.future_notes.write_into(target);
93 }
94}
95
96impl Deserializable for TransactionStoreUpdate {
97 fn read_from<R: ByteReader>(source: &mut R) -> Result<Self, DeserializationError> {
98 let executed_transaction = ExecutedTransaction::read_from(source)?;
99 let submission_height = BlockNumber::read_from(source)?;
100 let future_notes = Vec::<(NoteDetails, NoteTag)>::read_from(source)?;
101
102 Ok(Self {
103 executed_transaction,
104 submission_height,
105 future_notes,
106 note_updates: NoteUpdateTracker::default(),
107 new_tags: Vec::new(),
108 })
109 }
110}