@@ -71,32 +71,24 @@ use cuprate_epee_encoding::{
71
71
pub enum TxEntry {
72
72
/// This entry exists in the transaction pool.
73
73
InPool {
74
- as_hex : String ,
75
- as_json : String ,
74
+ /// This field is [flattened](https://serde.rs/field-attrs.html#flatten).
75
+ #[ cfg_attr( feature = "serde" , serde( flatten) ) ]
76
+ prefix : TxEntryPrefix ,
76
77
block_height : u64 ,
77
78
block_timestamp : u64 ,
78
79
confirmations : u64 ,
79
- double_spend_seen : bool ,
80
80
output_indices : Vec < u64 > ,
81
- prunable_as_hex : String ,
82
- prunable_hash : String ,
83
- pruned_as_hex : String ,
84
- tx_hash : String ,
85
81
#[ cfg_attr( feature = "serde" , serde( serialize_with = "serde_true" ) ) ]
86
82
/// Will always be serialized as `true`.
87
83
in_pool : bool ,
88
84
} ,
89
85
/// This entry _does not_ exist in the transaction pool.
90
86
NotInPool {
91
- as_hex : String ,
92
- as_json : String ,
93
- double_spend_seen : bool ,
94
- prunable_as_hex : String ,
95
- prunable_hash : String ,
96
- pruned_as_hex : String ,
87
+ /// This field is [flattened](https://serde.rs/field-attrs.html#flatten).
88
+ #[ cfg_attr( feature = "serde" , serde( flatten) ) ]
89
+ prefix : TxEntryPrefix ,
97
90
received_timestamp : u64 ,
98
91
relayed : bool ,
99
- tx_hash : String ,
100
92
#[ cfg_attr( feature = "serde" , serde( serialize_with = "serde_false" ) ) ]
101
93
/// Will always be serialized as `false`.
102
94
in_pool : bool ,
@@ -106,20 +98,29 @@ pub enum TxEntry {
106
98
impl Default for TxEntry {
107
99
fn default ( ) -> Self {
108
100
Self :: NotInPool {
109
- as_hex : String :: default ( ) ,
110
- as_json : String :: default ( ) ,
111
- double_spend_seen : bool:: default ( ) ,
112
- prunable_as_hex : String :: default ( ) ,
113
- prunable_hash : String :: default ( ) ,
114
- pruned_as_hex : String :: default ( ) ,
101
+ prefix : Default :: default ( ) ,
115
102
received_timestamp : u64:: default ( ) ,
116
103
relayed : bool:: default ( ) ,
117
- tx_hash : String :: default ( ) ,
118
104
in_pool : false ,
119
105
}
120
106
}
121
107
}
122
108
109
+ /// Common fields in all [`TxEntry`] variants.
110
+ #[ derive( Clone , Debug , Default , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
111
+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
112
+ pub struct TxEntryPrefix {
113
+ as_hex : String ,
114
+ /// `cuprate_rpc_types::json::tx::Transaction` should be used
115
+ /// to create this JSON string in a type-safe manner.
116
+ as_json : String ,
117
+ double_spend_seen : bool ,
118
+ tx_hash : String ,
119
+ prunable_as_hex : String ,
120
+ prunable_hash : String ,
121
+ pruned_as_hex : String ,
122
+ }
123
+
123
124
//---------------------------------------------------------------------------------------------------- Epee
124
125
#[ cfg( feature = "epee" ) ]
125
126
impl EpeeObjectBuilder < TxEntry > for ( ) {
0 commit comments