Skip to content

Commit

Permalink
[local_chain] Hide Arc implementation detail for CheckPoint
Browse files Browse the repository at this point in the history
  • Loading branch information
evanlinjin committed Jun 9, 2023
1 parent c9b648e commit 8776cde
Show file tree
Hide file tree
Showing 8 changed files with 164 additions and 138 deletions.
9 changes: 4 additions & 5 deletions crates/bdk/src/wallet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ impl<D> Wallet<D> {
}

/// Returns the latest checkpoint.
pub fn latest_checkpoint(&self) -> Option<Arc<CheckPoint>> {
pub fn latest_checkpoint(&self) -> Option<CheckPoint> {
self.chain.tip()
}

Expand Down Expand Up @@ -504,7 +504,7 @@ impl<D> Wallet<D> {
.range(height..)
.next()
.ok_or(InsertTxError::ConfirmationHeightCannotBeGreaterThanTip {
tip_height: self.chain.tip().map(|b| b.height),
tip_height: self.chain.tip().map(|b| b.height()),
tx_height: height,
})
.map(|(&_, cp)| ConfirmationTimeAnchor {
Expand Down Expand Up @@ -713,8 +713,7 @@ impl<D> Wallet<D> {
None => self
.chain
.tip()
.and_then(|cp| cp.height.into())
.map(|height| LockTime::from_height(height).expect("Invalid height")),
.map(|cp| LockTime::from_height(cp.height()).expect("Invalid height")),
h => h,
};

Expand Down Expand Up @@ -1286,7 +1285,7 @@ impl<D> Wallet<D> {
});
let current_height = sign_options
.assume_height
.or(self.chain.tip().map(|b| b.height));
.or(self.chain.tip().map(|b| b.height()));

debug!(
"Input #{} - {}, using `confirmation_height` = {:?}, `current_height` = {:?}",
Expand Down
6 changes: 3 additions & 3 deletions crates/bdk/tests/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ fn receive_output(wallet: &mut Wallet, value: u64, height: ConfirmationTime) ->
fn receive_output_in_latest_block(wallet: &mut Wallet, value: u64) -> OutPoint {
let height = match wallet.latest_checkpoint() {
Some(cp) => ConfirmationTime::Confirmed {
height: cp.height,
height: cp.height(),
time: 0,
},
None => ConfirmationTime::Unconfirmed { last_seen: 0 },
Expand Down Expand Up @@ -225,7 +225,7 @@ fn test_create_tx_fee_sniping_locktime_last_sync() {
// If there's no current_height we're left with using the last sync height
assert_eq!(
psbt.unsigned_tx.lock_time.0,
wallet.latest_checkpoint().unwrap().height
wallet.latest_checkpoint().unwrap().height()
);
}

Expand Down Expand Up @@ -1485,7 +1485,7 @@ fn test_bump_fee_drain_wallet() {
.insert_tx(
tx.clone(),
ConfirmationTime::Confirmed {
height: wallet.latest_checkpoint().unwrap().height,
height: wallet.latest_checkpoint().unwrap().height(),
time: 42_000,
},
)
Expand Down
Loading

0 comments on commit 8776cde

Please sign in to comment.