Skip to main content

thruput_node_types/
consensus.rs

1// -*-Rust-*-
2// Generated Code: DO NOT CHECK IN
3
4// Generated from xdrc commit: cb9cab8a8d69ace37c18d49b505f1e93ec802af8
5
6#![allow(non_camel_case_types)]
7#![allow(non_snake_case)]
8#![allow(non_upper_case_globals)]
9#![allow(unused_imports)]
10#![allow(dead_code)]
11#![allow(unused_variables)]
12#![allow(clippy::unnecessary_cast)]
13
14use crate::*;
15use core::option::Option;
16use core::ops::{Deref, DerefMut};
17
18#[cfg(feature = "std")]
19use std::io::{Read, Write};
20use xdrs::*;
21
22
23#[cfg(feature = "serde")]
24use ::serde::{{Serialize, Deserialize}};
25
26
27
28// clang-format on
29
30/// A serialized protocol upgrade, carried opaquely in `ConsensusValue`.
31pub type Upgrade = BytesM::<128>;
32
33/// The block commitment externalized by consensus.
34///
35/// `ConsensusValue` is the small value that systems use to identify
36/// a finalized Thruput block without the full transaction payload.
37/// Its XDR hash is the block identity (`ConsensusValueHash`), so every
38/// field is consensus-critical.
39///
40/// Travels on network.
41#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
42#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
43#[derive(schemars::JsonSchema)]
44#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
45#[repr(C)]
46pub struct ConsensusValue {
47    // Network protocol version.
48    pub protocol: Protocol,
49    pub ext: ExtensionPoint,
50    /// Hash of the parent block's `ConsensusValue`, linking the chain.
51    pub prev_hash: ConsensusValueHash,
52    /// The executed header of the proposed block.
53    pub proposal_header: ProposalHeader,
54    /// Commits to the block's transaction payload, which is kept out of the
55    /// value for compactness and travels separately in `ConsensusBasis`.
56    pub proposal_txs_hash: ProposalTxsHash,
57    /// Protocol upgrades selected by consensus to take effect at this block.
58    pub upgrades: VecM<Upgrade, 6>,
59}
60
61/// The validation payload for a consensus value.
62///
63/// `ConsensusBasis` pairs a `ConsensusValue` with the transaction payload it
64/// commits to but does not contain, letting a node reconstruct the `Proposal`
65/// as `{ header: value.proposal_header, transactions: proposal_txs }` and
66/// validate it. Gossiped and used during catchup.
67///
68/// Consensus agrees only on `value`; the basis has no consensus identity of its own.
69///
70/// Travels on network.
71#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
72#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
73#[derive(schemars::JsonSchema)]
74#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
75#[repr(C)]
76pub struct ConsensusBasis {
77    pub ext: ExtensionPoint,
78    pub value: ConsensusValue,
79    pub proposal_txs: ProposalTxs,
80}
81
82
83//
84// XDR internals below this point
85//
86
87