1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#[allow(unused_imports, clippy::wildcard_imports)]
use super::*;
/// StellarValue is an XDR Struct defined as:
///
/// ```text
/// struct StellarValue
/// {
/// Hash txSetHash; // transaction set to apply to previous ledger
/// TimePoint closeTime; // network close time
///
/// // upgrades to apply to the previous ledger (usually empty)
/// // this is a vector of encoded 'LedgerUpgrade' so that nodes can drop
/// // unknown steps during consensus if needed.
/// // see notes below on 'LedgerUpgrade' for more detail
/// // max size is dictated by number of upgrade types (+ room for future)
/// UpgradeType upgrades<6>;
///
/// // reserved for future use
/// union switch (StellarValueType v)
/// {
/// case STELLAR_VALUE_BASIC:
/// void;
/// case STELLAR_VALUE_SIGNED:
/// LedgerCloseValueSignature lcValueSignature;
/// #ifdef CAP_0083
/// case STELLAR_VALUE_EMPTY_TX_SET:
/// struct
/// {
/// Hash txSetHash;
/// Hash previousLedgerHash;
/// uint32 previousLedgerVersion;
/// LedgerCloseValueSignature lcValueSignature;
/// } proposedValue;
/// #endif
/// }
/// ext;
/// };
/// ```
///
#[cfg_attr(feature = "alloc", derive(Default))]
#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
#[cfg_attr(feature = "serde", cfg_eval::cfg_eval)]
#[cfg_attr(feature = "arbitrary", derive(Arbitrary))]
#[cfg_attr(
all(feature = "serde", feature = "alloc"),
serde_with::serde_as,
derive(serde::Serialize, serde::Deserialize),
serde(rename_all = "snake_case")
)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct StellarValue {
pub tx_set_hash: Hash,
pub close_time: TimePoint,
pub upgrades: VecM<UpgradeType, 6>,
pub ext: StellarValueExt,
}
impl ReadXdr for StellarValue {
#[cfg(feature = "std")]
fn read_xdr<R: Read>(r: &mut Limited<R>) -> Result<Self, Error> {
r.with_limited_depth(|r| {
Ok(Self {
tx_set_hash: Hash::read_xdr(r)?,
close_time: TimePoint::read_xdr(r)?,
upgrades: VecM::<UpgradeType, 6>::read_xdr(r)?,
ext: StellarValueExt::read_xdr(r)?,
})
})
}
}
impl WriteXdr for StellarValue {
#[cfg(feature = "std")]
fn write_xdr<W: Write>(&self, w: &mut Limited<W>) -> Result<(), Error> {
w.with_limited_depth(|w| {
self.tx_set_hash.write_xdr(w)?;
self.close_time.write_xdr(w)?;
self.upgrades.write_xdr(w)?;
self.ext.write_xdr(w)?;
Ok(())
})
}
}