thruput-node-types 0.64.0

Thruput node types shared by the node RPC bindings: transaction batches, block proposals, consensus values and common RPC results
Documentation
// -*-Rust-*-
// Generated Code: DO NOT CHECK IN

// Generated from xdrc commit: cb9cab8a8d69ace37c18d49b505f1e93ec802af8

#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(non_upper_case_globals)]
#![allow(unused_imports)]
#![allow(dead_code)]
#![allow(unused_variables)]
#![allow(clippy::unnecessary_cast)]

use crate::*;
use core::option::Option;
use core::ops::{Deref, DerefMut};

#[cfg(feature = "std")]
use std::io::{Read, Write};
use xdrs::*;


#[cfg(feature = "serde")]
use ::serde::{{Serialize, Deserialize}};



// clang-format on

/// Transaction-side payload for a proposal.
///
/// This is the payload a `ConsensusValue` commits to through
/// `ProposalTxsHash`. The signed transactions travel separately, since nodes
/// usually already hold them from transaction dissemination. Because the
/// payload names each transaction by its [`SignedTransactionHash`], a node
/// that holds a different signing of a body treats that transaction as
/// missing and fetches the proposer's encoding.
///
/// Travels on network.
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
#[derive(schemars::JsonSchema)]
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[repr(C)]
pub struct ProposalTxs {
    pub ext: ExtensionPoint,
    /// Signed hashes of the block's transactions, in execution order: the
    /// exact encodings the block executes.
    pub signed_hash: ParallelSignedTransactionHashBatch,
    /// Nondeterministic choices captured by the proposer, replayed by
    /// validators so re-execution reproduces the header outputs exactly.
    pub nondeterministic_data: ParallelNondeterministicProposalDataBatch,
}

/// Compatibility commitment over `ProposalTxs`.
///
/// This is not SHA-256 of the complete canonical XDR. It XORs the hash of a
/// base value with empty batches, the hashes of each raw batch segment, and
/// the XDR hash of each batch index with its raw bytes removed.
// 
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
#[derive(schemars::JsonSchema)]
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[repr(transparent)]
#[cfg_attr(feature = "serde", serde(transparent))]
pub struct ProposalTxsHash {
    inner: SHA256Hash,
}
impl From<SHA256Hash> for ProposalTxsHash {
    fn from(_inner: SHA256Hash) -> Self {
        Self { inner: _inner }
    }
}
impl ProposalTxsHash {
    pub fn into_inner(self) -> SHA256Hash {
        self.inner
    }
    pub const fn new(_inner: SHA256Hash) -> Self {
        Self { inner: _inner }
    }
}

impl Deref for ProposalTxsHash {
    type Target = SHA256Hash;

    fn deref(&self) -> &Self::Target {
        &self.inner
    }
}
impl DerefMut for ProposalTxsHash {
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.inner
    }
}

/// A candidate block: header plus the transaction metadata needed to
/// re-execute it.
///
/// Does not travel on network: nodes reconstruct it from a `ConsensusValue`
/// and its `ProposalTxs`.
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
#[derive(schemars::JsonSchema)]
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[repr(C)]
pub struct Proposal {
    pub header: ProposalHeader,
    pub transactions: ProposalTxs,
}

pub type OptProposal = Option::<Proposal>;

/// Summary of the previous finalized proposal, used by SCP leader selection.
///
/// Intentionally carries only the `ConsensusValueHash`: leader-election
/// pseudorandomness must not depend on transaction-payload availability.
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
#[derive(schemars::JsonSchema)]
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[repr(C)]
pub struct PrevProposalSummary {
    pub value_hash: ConsensusValueHash,
}


//
// XDR internals below this point
//