miden_client/transaction/
store_update.rs1use alloc::vec::Vec;
2
3use miden_objects::block::BlockNumber;
4use miden_objects::note::{NoteDetails, NoteTag};
5use miden_objects::transaction::ExecutedTransaction;
6use miden_tx::utils::{ByteReader, ByteWriter, Deserializable, DeserializationError, Serializable};
7
8use crate::note::NoteUpdateTracker;
9use crate::sync::NoteTagRecord;
10
11#[derive(Debug, Clone)]
17pub struct TransactionStoreUpdate {
18 executed_transaction: ExecutedTransaction,
20 submission_height: BlockNumber,
22 future_notes: Vec<(NoteDetails, NoteTag)>,
24 note_updates: NoteUpdateTracker,
26 new_tags: Vec<NoteTagRecord>,
28}
29
30impl TransactionStoreUpdate {
31 pub fn new(
42 executed_transaction: ExecutedTransaction,
43 submission_height: BlockNumber,
44 note_updates: NoteUpdateTracker,
45 future_notes: Vec<(NoteDetails, NoteTag)>,
46 new_tags: Vec<NoteTagRecord>,
47 ) -> Self {
48 Self {
49 executed_transaction,
50 submission_height,
51 future_notes,
52 note_updates,
53 new_tags,
54 }
55 }
56 pub fn executed_transaction(&self) -> &ExecutedTransaction {
58 &self.executed_transaction
59 }
60
61 pub fn submission_height(&self) -> BlockNumber {
63 self.submission_height
64 }
65
66 pub fn future_notes(&self) -> &[(NoteDetails, NoteTag)] {
68 &self.future_notes
69 }
70
71 pub fn note_updates(&self) -> &NoteUpdateTracker {
73 &self.note_updates
74 }
75
76 pub fn new_tags(&self) -> &[NoteTagRecord] {
78 &self.new_tags
79 }
80}
81
82impl Serializable for TransactionStoreUpdate {
83 fn write_into<W: ByteWriter>(&self, target: &mut W) {
84 self.executed_transaction.write_into(target);
85 self.submission_height.write_into(target);
86 self.future_notes.write_into(target);
87 }
88}
89
90impl Deserializable for TransactionStoreUpdate {
91 fn read_from<R: ByteReader>(source: &mut R) -> Result<Self, DeserializationError> {
92 let executed_transaction = ExecutedTransaction::read_from(source)?;
93 let submission_height = BlockNumber::read_from(source)?;
94 let future_notes = Vec::<(NoteDetails, NoteTag)>::read_from(source)?;
95
96 Ok(Self {
97 executed_transaction,
98 submission_height,
99 future_notes,
100 note_updates: NoteUpdateTracker::default(),
101 new_tags: Vec::new(),
102 })
103 }
104}