Skip to content

Commit 153c401

Browse files
committed
chore(core): fmt
1 parent 8e59e2c commit 153c401

File tree

3 files changed

+22
-15
lines changed

3 files changed

+22
-15
lines changed

crates/core/benches/checkpoint_skiplist.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use bdk_core::CheckPoint;
2-
use bitcoin::BlockHash;
32
use bitcoin::hashes::Hash;
4-
use criterion::{black_box, criterion_group, criterion_main, Criterion, Bencher};
3+
use bitcoin::BlockHash;
4+
use criterion::{black_box, criterion_group, criterion_main, Bencher, Criterion};
55

66
/// Create a checkpoint chain with the given length
77
fn create_checkpoint_chain(length: u32) -> CheckPoint<BlockHash> {
@@ -206,4 +206,4 @@ criterion_group!(
206206
bench_skip_pointer_analysis
207207
);
208208

209-
criterion_main!(benches);
209+
criterion_main!(benches);

crates/core/src/checkpoint.rs

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -235,12 +235,11 @@ impl<D> CheckPoint<D> {
235235
}
236236

237237
// Now iterate normally from the found starting point
238-
current.into_iter()
239-
.take_while(move |cp| match start_bound {
240-
core::ops::Bound::Included(inc_bound) => cp.height() >= inc_bound,
241-
core::ops::Bound::Excluded(exc_bound) => cp.height() > exc_bound,
242-
core::ops::Bound::Unbounded => true,
243-
})
238+
current.into_iter().take_while(move |cp| match start_bound {
239+
core::ops::Bound::Included(inc_bound) => cp.height() >= inc_bound,
240+
core::ops::Bound::Excluded(exc_bound) => cp.height() > exc_bound,
241+
core::ops::Bound::Unbounded => true,
242+
})
244243
}
245244

246245
/// Returns the checkpoint at `height` if one exists, otherwise the nearest checkpoint at a
@@ -390,12 +389,16 @@ where
390389
let base_index = result.index();
391390

392391
// First insert the new block
393-
result = result.push_with_index(height, data, base_index + 1).expect("height is valid");
392+
result = result
393+
.push_with_index(height, data, base_index + 1)
394+
.expect("height is valid");
394395

395396
// Then re-add all the tail blocks with updated indices
396397
let mut current_index = base_index + 2;
397398
for (h, d) in tail.into_iter().rev() {
398-
result = result.push_with_index(h, d, current_index).expect("tail is in order");
399+
result = result
400+
.push_with_index(h, d, current_index)
401+
.expect("tail is in order");
399402
current_index += 1;
400403
}
401404

@@ -406,7 +409,9 @@ where
406409
fn push_with_index(self, height: u32, data: D, new_index: u32) -> Result<Self, Self> {
407410
if self.height() < height {
408411
// Calculate skip pointer
409-
let skip = if new_index >= CHECKPOINT_SKIP_INTERVAL && new_index % CHECKPOINT_SKIP_INTERVAL == 0 {
412+
let skip = if new_index >= CHECKPOINT_SKIP_INTERVAL
413+
&& new_index % CHECKPOINT_SKIP_INTERVAL == 0
414+
{
410415
// Navigate back CHECKPOINT_SKIP_INTERVAL checkpoints
411416
let target_index = new_index - CHECKPOINT_SKIP_INTERVAL;
412417
let mut current = Some(self.0.clone());
@@ -453,7 +458,9 @@ where
453458
let new_index = self.0.index + 1;
454459

455460
// Calculate skip pointer
456-
let skip = if new_index >= CHECKPOINT_SKIP_INTERVAL && new_index % CHECKPOINT_SKIP_INTERVAL == 0 {
461+
let skip = if new_index >= CHECKPOINT_SKIP_INTERVAL
462+
&& new_index % CHECKPOINT_SKIP_INTERVAL == 0
463+
{
457464
// Navigate back CHECKPOINT_SKIP_INTERVAL checkpoints
458465
let mut current = Some(self.0.clone());
459466
let mut steps = 0;

crates/core/tests/test_checkpoint_skiplist.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use bdk_core::CheckPoint;
2-
use bitcoin::BlockHash;
32
use bitcoin::hashes::Hash;
3+
use bitcoin::BlockHash;
44

55
#[test]
66
fn test_skiplist_indices() {
@@ -193,4 +193,4 @@ fn test_skiplist_range_uses_skip_pointers() {
193193
assert_eq!(range_items.len(), 51);
194194
assert_eq!(range_items.first().unwrap().height(), 500);
195195
assert_eq!(range_items.last().unwrap().height(), 450);
196-
}
196+
}

0 commit comments

Comments
 (0)