Skip to content

Commit b4ef265

Browse files
committed
f Account for BestBlock dropping accessor methods
1 parent f863904 commit b4ef265

File tree

4 files changed

+10
-28
lines changed

4 files changed

+10
-28
lines changed

src/event.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ where
347347
let confirmation_target = ConfirmationTarget::NonAnchorChannelFee;
348348

349349
// We set nLockTime to the current height to discourage fee sniping.
350-
let cur_height = self.channel_manager.current_best_block().height();
350+
let cur_height = self.channel_manager.current_best_block().height;
351351
let locktime = LockTime::from_height(cur_height).unwrap_or(LockTime::ZERO);
352352

353353
// Sign the final funding transaction and broadcast it.

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ pub use error::Error as NodeError;
107107
use error::Error;
108108

109109
pub use event::Event;
110-
pub use types::{BestBlock, ChannelConfig};
110+
pub use types::ChannelConfig;
111111

112112
pub use io::utils::generate_entropy_mnemonic;
113113

@@ -138,7 +138,7 @@ pub use types::{ChannelDetails, PeerDetails, UserChannelId};
138138

139139
use logger::{log_error, log_info, log_trace, FilesystemLogger, Logger};
140140

141-
use lightning::chain::Confirm;
141+
use lightning::chain::{BestBlock, Confirm};
142142
use lightning::ln::channelmanager::{self, PaymentId, RecipientOnionFields, Retry};
143143
use lightning::ln::msgs::SocketAddress;
144144
use lightning::ln::{PaymentHash, PaymentPreimage};

src/sweep.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ where
199199
fn rebroadcast_if_necessary(&self) {
200200
let (cur_height, cur_hash) = {
201201
let best_block = self.best_block.lock().unwrap();
202-
(best_block.height(), best_block.block_hash())
202+
(best_block.height, best_block.block_hash)
203203
};
204204

205205
let mut respend_descriptors = Vec::new();
@@ -277,7 +277,7 @@ where
277277
}
278278

279279
fn prune_confirmed_outputs(&self) {
280-
let cur_height = self.best_block.lock().unwrap().height();
280+
let cur_height = self.best_block.lock().unwrap().height;
281281
let mut locked_outputs = self.outputs.lock().unwrap();
282282

283283
// Prune all outputs that have sufficient depth by now.
@@ -370,9 +370,9 @@ where
370370
) {
371371
{
372372
let best_block = self.best_block.lock().unwrap();
373-
assert_eq!(best_block.block_hash(), header.prev_blockhash,
373+
assert_eq!(best_block.block_hash, header.prev_blockhash,
374374
"Blocks must be connected in chain-order - the connected header must build on the last connected header");
375-
assert_eq!(best_block.height(), height - 1,
375+
assert_eq!(best_block.height, height - 1,
376376
"Blocks must be connected in chain-order - the connected block height must be one greater than the previous height");
377377
}
378378

@@ -384,9 +384,9 @@ where
384384
let new_height = height - 1;
385385
{
386386
let mut best_block = self.best_block.lock().unwrap();
387-
assert_eq!(best_block.block_hash(), header.block_hash(),
387+
assert_eq!(best_block.block_hash, header.block_hash(),
388388
"Blocks must be disconnected in chain-order - the disconnected header must be the last connected header");
389-
assert_eq!(best_block.height(), height,
389+
assert_eq!(best_block.height, height,
390390
"Blocks must be disconnected in chain-order - the disconnected block must have the correct height");
391391
*best_block = BestBlock::new(header.prev_blockhash, new_height)
392392
}

src/types.rs

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use crate::sweep::OutputSweeper;
44

55
use lightning::blinded_path::BlindedPath;
66
use lightning::chain::chainmonitor;
7-
use lightning::chain::BestBlock as LdkBestBlock;
87
use lightning::ln::channelmanager::ChannelDetails as LdkChannelDetails;
98
use lightning::ln::msgs::RoutingMessageHandler;
109
use lightning::ln::msgs::SocketAddress;
@@ -21,7 +20,7 @@ use lightning_net_tokio::SocketDescriptor;
2120
use lightning_transaction_sync::EsploraSyncClient;
2221

2322
use bitcoin::secp256k1::{self, PublicKey, Secp256k1};
24-
use bitcoin::{BlockHash, OutPoint};
23+
use bitcoin::OutPoint;
2524

2625
use std::sync::{Arc, Mutex, RwLock};
2726

@@ -454,20 +453,3 @@ impl Default for ChannelConfig {
454453
LdkChannelConfig::default().into()
455454
}
456455
}
457-
458-
/// The best known block as identified by its hash and height.
459-
#[derive(Debug, Clone, PartialEq, Eq)]
460-
pub struct BestBlock {
461-
/// The block's hash
462-
pub block_hash: BlockHash,
463-
/// The height at which the block was confirmed.
464-
pub height: u32,
465-
}
466-
467-
impl From<LdkBestBlock> for BestBlock {
468-
fn from(value: LdkBestBlock) -> Self {
469-
let block_hash = value.block_hash();
470-
let height = value.height();
471-
Self { block_hash, height }
472-
}
473-
}

0 commit comments

Comments
 (0)