Skip to main content

stellar_xdr/generated/
ledger_close_meta_v2.rs

1#[allow(unused_imports, clippy::wildcard_imports)]
2use super::*;
3
4/// LedgerCloseMetaV2 is an XDR Struct defined as:
5///
6/// ```text
7/// struct LedgerCloseMetaV2
8/// {
9///     LedgerCloseMetaExt ext;
10///
11///     LedgerHeaderHistoryEntry ledgerHeader;
12///
13///     GeneralizedTransactionSet txSet;
14///
15///     // NB: transactions are sorted in apply order here
16///     // fees for all transactions are processed first
17///     // followed by applying transactions
18///     TransactionResultMetaV1 txProcessing<>;
19///
20///     // upgrades are applied last
21///     UpgradeEntryMeta upgradesProcessing<>;
22///
23///     // other misc information attached to the ledger close
24///     SCPHistoryEntry scpInfo<>;
25///
26///     // Size in bytes of live Soroban state, to support downstream
27///     // systems calculating storage fees correctly.
28///     uint64 totalByteSizeOfLiveSorobanState;
29///
30///     // TTL and data/code keys that have been evicted at this ledger.
31///     LedgerKey evictedKeys<>;
32/// };
33/// ```
34///
35#[cfg_attr(feature = "alloc", derive(Default))]
36#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
37#[cfg_attr(feature = "serde", cfg_eval::cfg_eval)]
38#[cfg_attr(feature = "arbitrary", derive(Arbitrary))]
39#[cfg_attr(
40    all(feature = "serde", feature = "alloc"),
41    serde_with::serde_as,
42    derive(serde::Serialize, serde::Deserialize),
43    serde(rename_all = "snake_case")
44)]
45#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
46pub struct LedgerCloseMetaV2 {
47    pub ext: LedgerCloseMetaExt,
48    pub ledger_header: LedgerHeaderHistoryEntry,
49    pub tx_set: GeneralizedTransactionSet,
50    pub tx_processing: VecM<TransactionResultMetaV1>,
51    pub upgrades_processing: VecM<UpgradeEntryMeta>,
52    pub scp_info: VecM<ScpHistoryEntry>,
53    #[cfg_attr(
54        all(feature = "serde", feature = "alloc"),
55        serde_as(as = "NumberOrString")
56    )]
57    pub total_byte_size_of_live_soroban_state: u64,
58    pub evicted_keys: VecM<LedgerKey>,
59}
60
61impl ReadXdr for LedgerCloseMetaV2 {
62    #[cfg(feature = "std")]
63    fn read_xdr<R: Read>(r: &mut Limited<R>) -> Result<Self, Error> {
64        r.with_limited_depth(|r| {
65            Ok(Self {
66                ext: LedgerCloseMetaExt::read_xdr(r)?,
67                ledger_header: LedgerHeaderHistoryEntry::read_xdr(r)?,
68                tx_set: GeneralizedTransactionSet::read_xdr(r)?,
69                tx_processing: VecM::<TransactionResultMetaV1>::read_xdr(r)?,
70                upgrades_processing: VecM::<UpgradeEntryMeta>::read_xdr(r)?,
71                scp_info: VecM::<ScpHistoryEntry>::read_xdr(r)?,
72                total_byte_size_of_live_soroban_state: u64::read_xdr(r)?,
73                evicted_keys: VecM::<LedgerKey>::read_xdr(r)?,
74            })
75        })
76    }
77}
78
79impl WriteXdr for LedgerCloseMetaV2 {
80    #[cfg(feature = "std")]
81    fn write_xdr<W: Write>(&self, w: &mut Limited<W>) -> Result<(), Error> {
82        w.with_limited_depth(|w| {
83            self.ext.write_xdr(w)?;
84            self.ledger_header.write_xdr(w)?;
85            self.tx_set.write_xdr(w)?;
86            self.tx_processing.write_xdr(w)?;
87            self.upgrades_processing.write_xdr(w)?;
88            self.scp_info.write_xdr(w)?;
89            self.total_byte_size_of_live_soroban_state.write_xdr(w)?;
90            self.evicted_keys.write_xdr(w)?;
91            Ok(())
92        })
93    }
94}