mirror of
https://github.com/hinto-janai/cuprate.git
synced 2025-01-10 21:04:59 +00:00
cuprate-rpc-types: common TxEntry
fields into prefix struct
This commit is contained in:
parent
7dbd514a2d
commit
c06d0a47a2
1 changed files with 22 additions and 25 deletions
|
@ -71,36 +71,24 @@ use cuprate_epee_encoding::{
|
||||||
pub enum TxEntry {
|
pub enum TxEntry {
|
||||||
/// This entry exists in the transaction pool.
|
/// This entry exists in the transaction pool.
|
||||||
InPool {
|
InPool {
|
||||||
as_hex: String,
|
/// This field is flattened.
|
||||||
/// `cuprate_rpc_types::json::tx::Transaction` should be used
|
#[cfg_attr(feature = "serde", serde(flatten))]
|
||||||
/// to create this JSON string in a type-safe manner.
|
prefix: TxEntryPrefix,
|
||||||
as_json: String,
|
|
||||||
block_height: u64,
|
block_height: u64,
|
||||||
block_timestamp: u64,
|
block_timestamp: u64,
|
||||||
confirmations: u64,
|
confirmations: u64,
|
||||||
double_spend_seen: bool,
|
|
||||||
output_indices: Vec<u64>,
|
output_indices: Vec<u64>,
|
||||||
prunable_as_hex: String,
|
|
||||||
prunable_hash: String,
|
|
||||||
pruned_as_hex: String,
|
|
||||||
tx_hash: String,
|
|
||||||
#[cfg_attr(feature = "serde", serde(serialize_with = "serde_true"))]
|
#[cfg_attr(feature = "serde", serde(serialize_with = "serde_true"))]
|
||||||
/// Will always be serialized as `true`.
|
/// Will always be serialized as `true`.
|
||||||
in_pool: bool,
|
in_pool: bool,
|
||||||
},
|
},
|
||||||
/// This entry _does not_ exist in the transaction pool.
|
/// This entry _does not_ exist in the transaction pool.
|
||||||
NotInPool {
|
NotInPool {
|
||||||
as_hex: String,
|
/// This field is flattened.
|
||||||
/// `cuprate_rpc_types::json::tx::Transaction` should be used
|
#[cfg_attr(feature = "serde", serde(flatten))]
|
||||||
/// to create this JSON string in a type-safe manner.
|
prefix: TxEntryPrefix,
|
||||||
as_json: String,
|
|
||||||
double_spend_seen: bool,
|
|
||||||
prunable_as_hex: String,
|
|
||||||
prunable_hash: String,
|
|
||||||
pruned_as_hex: String,
|
|
||||||
received_timestamp: u64,
|
received_timestamp: u64,
|
||||||
relayed: bool,
|
relayed: bool,
|
||||||
tx_hash: String,
|
|
||||||
#[cfg_attr(feature = "serde", serde(serialize_with = "serde_false"))]
|
#[cfg_attr(feature = "serde", serde(serialize_with = "serde_false"))]
|
||||||
/// Will always be serialized as `false`.
|
/// Will always be serialized as `false`.
|
||||||
in_pool: bool,
|
in_pool: bool,
|
||||||
|
@ -110,20 +98,29 @@ pub enum TxEntry {
|
||||||
impl Default for TxEntry {
|
impl Default for TxEntry {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self::NotInPool {
|
Self::NotInPool {
|
||||||
as_hex: String::default(),
|
prefix: Default::default(),
|
||||||
as_json: String::default(),
|
|
||||||
double_spend_seen: bool::default(),
|
|
||||||
prunable_as_hex: String::default(),
|
|
||||||
prunable_hash: String::default(),
|
|
||||||
pruned_as_hex: String::default(),
|
|
||||||
received_timestamp: u64::default(),
|
received_timestamp: u64::default(),
|
||||||
relayed: bool::default(),
|
relayed: bool::default(),
|
||||||
tx_hash: String::default(),
|
|
||||||
in_pool: false,
|
in_pool: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Common fields in all [`TxEntry`] variants.
|
||||||
|
#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
|
pub struct TxEntryPrefix {
|
||||||
|
as_hex: String,
|
||||||
|
/// `cuprate_rpc_types::json::tx::Transaction` should be used
|
||||||
|
/// to create this JSON string in a type-safe manner.
|
||||||
|
as_json: String,
|
||||||
|
double_spend_seen: bool,
|
||||||
|
tx_hash: String,
|
||||||
|
prunable_as_hex: String,
|
||||||
|
prunable_hash: String,
|
||||||
|
pruned_as_hex: String,
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- Epee
|
//---------------------------------------------------------------------------------------------------- Epee
|
||||||
#[cfg(feature = "epee")]
|
#[cfg(feature = "epee")]
|
||||||
impl EpeeObjectBuilder<TxEntry> for () {
|
impl EpeeObjectBuilder<TxEntry> for () {
|
||||||
|
|
Loading…
Reference in a new issue