@@ -6,7 +6,6 @@ use core::ops::RangeBounds;
66use crate :: collections:: BTreeMap ;
77use crate :: { BlockId , ChainOracle } ;
88use alloc:: sync:: Arc ;
9- use alloc:: vec:: Vec ;
109use bitcoin:: block:: Header ;
1110use bitcoin:: BlockHash ;
1211
@@ -36,6 +35,14 @@ struct CPInner {
3635 prev : Option < Arc < CPInner > > ,
3736}
3837
38+ impl PartialEq for CheckPoint {
39+ fn eq ( & self , other : & Self ) -> bool {
40+ let self_cps = self . iter ( ) . map ( |cp| cp. block_id ( ) ) ;
41+ let other_cps = other. iter ( ) . map ( |cp| cp. block_id ( ) ) ;
42+ self_cps. eq ( other_cps)
43+ }
44+ }
45+
3946impl CheckPoint {
4047 /// Construct a new base block at the front of a linked list.
4148 pub fn new ( block : BlockId ) -> Self {
@@ -220,7 +227,7 @@ impl IntoIterator for CheckPoint {
220227/// Script-pubkey based syncing mechanisms may not introduce transactions in a chronological order
221228/// so some updates require introducing older blocks (to anchor older transactions). For
222229/// script-pubkey based syncing, `introduce_older_blocks` would typically be `true`.
223- #[ derive( Debug , Clone ) ]
230+ #[ derive( Debug , Clone , PartialEq ) ]
224231pub struct Update {
225232 /// The update chain's new tip.
226233 pub tip : CheckPoint ,
@@ -234,23 +241,11 @@ pub struct Update {
234241}
235242
236243/// This is a local implementation of [`ChainOracle`].
237- #[ derive( Debug , Clone ) ]
244+ #[ derive( Debug , Clone , PartialEq ) ]
238245pub struct LocalChain {
239246 tip : CheckPoint ,
240247}
241248
242- impl PartialEq for LocalChain {
243- fn eq ( & self , other : & Self ) -> bool {
244- self . iter_checkpoints ( )
245- . map ( |cp| cp. block_id ( ) )
246- . collect :: < Vec < _ > > ( )
247- == other
248- . iter_checkpoints ( )
249- . map ( |cp| cp. block_id ( ) )
250- . collect :: < Vec < _ > > ( )
251- }
252- }
253-
254249// TODO: Figure out whether we can get rid of this
255250impl From < LocalChain > for BTreeMap < u32 , BlockHash > {
256251 fn from ( value : LocalChain ) -> Self {
0 commit comments