Skip to content

Commit 9e752c5

Browse files
committed
Rename start_block to checkpoint
1 parent 9dad04f commit 9e752c5

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

node/src/source.rs

+12-16
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ impl BlockFetcher {
324324
self.job_id.fetch_add(1, Ordering::SeqCst);
325325
}
326326

327-
pub fn start(&self, mut start_block: ChainAnchor) {
327+
pub fn start(&self, mut checkpoint: ChainAnchor) {
328328
self.stop();
329329

330330
let job_id = self.job_id.load(Ordering::SeqCst);
@@ -357,20 +357,20 @@ impl BlockFetcher {
357357
}
358358
};
359359

360-
if tip > start_block.height {
360+
if tip > checkpoint.height {
361361
let res = Self::run_workers(
362362
job_id,
363363
current_task.clone(),
364364
task_rpc.clone(),
365365
task_sender.clone(),
366-
start_block,
366+
checkpoint,
367367
tip,
368368
num_workers,
369369
);
370370

371371
match res {
372372
Ok(new_tip) => {
373-
start_block = new_tip;
373+
checkpoint = new_tip;
374374
}
375375
Err(e) => {
376376
_ = task_sender.send(BlockEvent::Error(e));
@@ -608,7 +608,7 @@ fn val(c: u8, idx: usize) -> Result<u8, FromHexError> {
608608

609609
impl BitcoinRpcError {
610610
fn is_temporary(&self) -> bool {
611-
return match self {
611+
match self {
612612
BitcoinRpcError::Transport(e) => {
613613
if e.is_timeout() || e.is_connect() {
614614
return true;
@@ -635,7 +635,7 @@ impl BitcoinRpcError {
635635
)
636636
}
637637
_ => false,
638-
};
638+
}
639639
}
640640
}
641641

@@ -686,7 +686,7 @@ impl ErrorForRpcBlocking for reqwest::blocking::Response {
686686
return Err(BitcoinRpcError::Rpc(e));
687687
}
688688

689-
return Ok(rpc_res.result.unwrap());
689+
Ok(rpc_res.result.unwrap())
690690
}
691691
}
692692

@@ -735,11 +735,7 @@ impl BlockSource for BitcoinBlockSource {
735735

736736
#[cfg(test)]
737737
mod test {
738-
use protocol::{
739-
bitcoin,
740-
bitcoin::{BlockHash, Network},
741-
constants::ChainAnchor,
742-
};
738+
use protocol::{bitcoin::BlockHash, constants::ChainAnchor};
743739

744740
use crate::source::{BitcoinRpc, BitcoinRpcAuth, BlockEvent, BlockFetcher};
745741

@@ -753,17 +749,17 @@ mod test {
753749
let client = reqwest::blocking::Client::new();
754750
let count: u32 = rpc.send_json_blocking(&client, &rpc.get_block_count())?;
755751

756-
let start_block = count - 1;
752+
let checkpoint = count - 10;
757753
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))?;
759755

760756
let (fetcher, receiver) = BlockFetcher::new(rpc, client, 8);
761757

762-
println!("fetcher starting from block {}", start_block);
758+
println!("fetcher checkpoint block {}", checkpoint);
763759

764760
fetcher.start(ChainAnchor {
765761
hash: start_block_hash,
766-
height: start_block,
762+
height: checkpoint,
767763
});
768764

769765
println!("fetcher receiving blocks");

0 commit comments

Comments
 (0)