@@ -324,7 +324,7 @@ impl BlockFetcher {
324
324
self . job_id . fetch_add ( 1 , Ordering :: SeqCst ) ;
325
325
}
326
326
327
- pub fn start ( & self , mut start_block : ChainAnchor ) {
327
+ pub fn start ( & self , mut checkpoint : ChainAnchor ) {
328
328
self . stop ( ) ;
329
329
330
330
let job_id = self . job_id . load ( Ordering :: SeqCst ) ;
@@ -357,20 +357,20 @@ impl BlockFetcher {
357
357
}
358
358
} ;
359
359
360
- if tip > start_block . height {
360
+ if tip > checkpoint . height {
361
361
let res = Self :: run_workers (
362
362
job_id,
363
363
current_task. clone ( ) ,
364
364
task_rpc. clone ( ) ,
365
365
task_sender. clone ( ) ,
366
- start_block ,
366
+ checkpoint ,
367
367
tip,
368
368
num_workers,
369
369
) ;
370
370
371
371
match res {
372
372
Ok ( new_tip) => {
373
- start_block = new_tip;
373
+ checkpoint = new_tip;
374
374
}
375
375
Err ( e) => {
376
376
_ = task_sender. send ( BlockEvent :: Error ( e) ) ;
@@ -608,7 +608,7 @@ fn val(c: u8, idx: usize) -> Result<u8, FromHexError> {
608
608
609
609
impl BitcoinRpcError {
610
610
fn is_temporary ( & self ) -> bool {
611
- return match self {
611
+ match self {
612
612
BitcoinRpcError :: Transport ( e) => {
613
613
if e. is_timeout ( ) || e. is_connect ( ) {
614
614
return true ;
@@ -635,7 +635,7 @@ impl BitcoinRpcError {
635
635
)
636
636
}
637
637
_ => false ,
638
- } ;
638
+ }
639
639
}
640
640
}
641
641
@@ -686,7 +686,7 @@ impl ErrorForRpcBlocking for reqwest::blocking::Response {
686
686
return Err ( BitcoinRpcError :: Rpc ( e) ) ;
687
687
}
688
688
689
- return Ok ( rpc_res. result . unwrap ( ) ) ;
689
+ Ok ( rpc_res. result . unwrap ( ) )
690
690
}
691
691
}
692
692
@@ -735,11 +735,7 @@ impl BlockSource for BitcoinBlockSource {
735
735
736
736
#[ cfg( test) ]
737
737
mod test {
738
- use protocol:: {
739
- bitcoin,
740
- bitcoin:: { BlockHash , Network } ,
741
- constants:: ChainAnchor ,
742
- } ;
738
+ use protocol:: { bitcoin:: BlockHash , constants:: ChainAnchor } ;
743
739
744
740
use crate :: source:: { BitcoinRpc , BitcoinRpcAuth , BlockEvent , BlockFetcher } ;
745
741
@@ -753,17 +749,17 @@ mod test {
753
749
let client = reqwest:: blocking:: Client :: new ( ) ;
754
750
let count: u32 = rpc. send_json_blocking ( & client, & rpc. get_block_count ( ) ) ?;
755
751
756
- let start_block = count - 1 ;
752
+ let checkpoint = count - 10 ;
757
753
let start_block_hash: BlockHash =
758
- rpc. send_json_blocking ( & client, & rpc. get_block_hash ( start_block ) ) ?;
754
+ rpc. send_json_blocking ( & client, & rpc. get_block_hash ( checkpoint ) ) ?;
759
755
760
756
let ( fetcher, receiver) = BlockFetcher :: new ( rpc, client, 8 ) ;
761
757
762
- println ! ( "fetcher starting from block {}" , start_block ) ;
758
+ println ! ( "fetcher checkpoint block {}" , checkpoint ) ;
763
759
764
760
fetcher. start ( ChainAnchor {
765
761
hash : start_block_hash,
766
- height : start_block ,
762
+ height : checkpoint ,
767
763
} ) ;
768
764
769
765
println ! ( "fetcher receiving blocks" ) ;
0 commit comments