@@ -87,6 +87,59 @@ pub struct BlockTime {
8787 pub height : u32 ,
8888}
8989
90+ /// Information about a [`Block`].
91+ #[ derive( Debug , Clone , Deserialize ) ]
92+ pub struct BlockInformation {
93+ /// The block's [`BlockHash`].
94+ pub id : BlockHash ,
95+ /// The block's height.
96+ pub height : u32 ,
97+ /// The block's version.
98+ pub version : block:: Version ,
99+ /// The block's timestamp.
100+ pub timestamp : u64 ,
101+ /// The block's transaction count.
102+ pub tx_count : u64 ,
103+ /// The block's size, in bytes.
104+ pub size : usize ,
105+ /// The block's weight.
106+ pub weight : u64 ,
107+ /// The merkle root of the transactions in the block.
108+ pub merkle_root : hash_types:: TxMerkleNode ,
109+ /// The [`BlockHash`] of the previous block (`None` for the genesis block).
110+ pub previousblockhash : Option < BlockHash > ,
111+ /// The block's MTP (Median Time Past).
112+ pub mediantime : u64 ,
113+ /// The block's nonce value.
114+ pub nonce : u32 ,
115+ /// The block's `bits` value as a [`CompactTarget`].
116+ pub bits : CompactTarget ,
117+ /// The block's difficulty target value.
118+ pub difficulty : f64 ,
119+ }
120+
121+ impl PartialEq for BlockInformation {
122+ fn eq ( & self , other : & Self ) -> bool {
123+ let Self { difficulty : d1, .. } = self ;
124+ let Self { difficulty : d2, .. } = other;
125+
126+ self . id == other. id
127+ && self . height == other. height
128+ && self . version == other. version
129+ && self . timestamp == other. timestamp
130+ && self . tx_count == other. tx_count
131+ && self . size == other. size
132+ && self . weight == other. weight
133+ && self . merkle_root == other. merkle_root
134+ && self . previousblockhash == other. previousblockhash
135+ && self . mediantime == other. mediantime
136+ && self . nonce == other. nonce
137+ && self . bits == other. bits
138+ && ( ( d1. is_nan ( ) && d2. is_nan ( ) ) || ( d1 == d2) )
139+ }
140+ }
141+ impl Eq for BlockInformation { }
142+
90143#[ derive( Debug , Clone , Deserialize , PartialEq , Eq ) ]
91144pub struct BlockSummary {
92145 pub id : BlockHash ,
0 commit comments