Skip to content

Commit 896cf97

Browse files
channelmanager: remove unused ChainWatchInterface field
Since the channelmanager no longer self-registers as a ChainListener with the ChainWatchInterface, the field is no longer needed.
1 parent 5522ea4 commit 896cf97

File tree

3 files changed

+6
-16
lines changed

3 files changed

+6
-16
lines changed

src/ln/channelmanager.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use secp256k1::Secp256k1;
2525
use secp256k1::ecdh::SharedSecret;
2626
use secp256k1;
2727

28-
use chain::chaininterface::{BroadcasterInterface,ChainListener,ChainWatchInterface,FeeEstimator};
28+
use chain::chaininterface::{BroadcasterInterface,ChainListener,FeeEstimator};
2929
use chain::transaction::OutPoint;
3030
use ln::channel::{Channel, ChannelError};
3131
use ln::channelmonitor::{ChannelMonitor, ChannelMonitorUpdateErr, ManyChannelMonitor, CLTV_CLAIM_BUFFER, LATENCY_GRACE_PERIOD_BLOCKS, ANTI_REORG_DELAY};
@@ -323,7 +323,6 @@ pub struct ChannelManager {
323323
genesis_hash: Sha256dHash,
324324
fee_estimator: Arc<FeeEstimator>,
325325
monitor: Arc<ManyChannelMonitor>,
326-
chain_monitor: Arc<ChainWatchInterface>,
327326
tx_broadcaster: Arc<BroadcasterInterface>,
328327

329328
#[cfg(test)]
@@ -585,15 +584,14 @@ impl ChannelManager {
585584
/// Non-proportional fees are fixed according to our risk using the provided fee estimator.
586585
///
587586
/// panics if channel_value_satoshis is >= `MAX_FUNDING_SATOSHIS`!
588-
pub fn new(network: Network, feeest: Arc<FeeEstimator>, monitor: Arc<ManyChannelMonitor>, chain_monitor: Arc<ChainWatchInterface>, tx_broadcaster: Arc<BroadcasterInterface>, logger: Arc<Logger>,keys_manager: Arc<KeysInterface>, config: UserConfig) -> Result<Arc<ChannelManager>, secp256k1::Error> {
587+
pub fn new(network: Network, feeest: Arc<FeeEstimator>, monitor: Arc<ManyChannelMonitor>, tx_broadcaster: Arc<BroadcasterInterface>, logger: Arc<Logger>,keys_manager: Arc<KeysInterface>, config: UserConfig) -> Result<Arc<ChannelManager>, secp256k1::Error> {
589588
let secp_ctx = Secp256k1::new();
590589

591590
let res = Arc::new(ChannelManager {
592591
default_configuration: config.clone(),
593592
genesis_hash: genesis_block(network).header.bitcoin_hash(),
594593
fee_estimator: feeest.clone(),
595594
monitor: monitor.clone(),
596-
chain_monitor,
597595
tx_broadcaster,
598596

599597
latest_block_height: AtomicUsize::new(0), //TODO: Get an init value
@@ -3087,10 +3085,7 @@ pub struct ChannelManagerReadArgs<'a> {
30873085
/// you have deserialized ChannelMonitors separately and will add them to your
30883086
/// ManyChannelMonitor after deserializing this ChannelManager.
30893087
pub monitor: Arc<ManyChannelMonitor>,
3090-
/// The ChainWatchInterface for use in the ChannelManager in the future.
3091-
///
3092-
/// No calls to the ChainWatchInterface will be made during deserialization.
3093-
pub chain_monitor: Arc<ChainWatchInterface>,
3088+
30943089
/// The BroadcasterInterface which will be used in the ChannelManager in the future and may be
30953090
/// used to broadcast the latest local commitment transactions of channels which must be
30963091
/// force-closed during deserialization.
@@ -3116,7 +3111,7 @@ pub struct ChannelManagerReadArgs<'a> {
31163111
}
31173112

31183113
impl<'a, R : ::std::io::Read> ReadableArgs<R, ChannelManagerReadArgs<'a>> for (Sha256dHash, ChannelManager) {
3119-
fn read(reader: &mut R, args: ChannelManagerReadArgs<'a>) -> Result<Self, DecodeError> {
3114+
fn read(reader: &mut R, args: ChannelManagerReadArgs) -> Result<Self, DecodeError> {
31203115
let _ver: u8 = Readable::read(reader)?;
31213116
let min_ver: u8 = Readable::read(reader)?;
31223117
if min_ver > SERIALIZATION_VERSION {
@@ -3193,7 +3188,6 @@ impl<'a, R : ::std::io::Read> ReadableArgs<R, ChannelManagerReadArgs<'a>> for (S
31933188
genesis_hash,
31943189
fee_estimator: args.fee_estimator,
31953190
monitor: args.monitor,
3196-
chain_monitor: args.chain_monitor,
31973191
tx_broadcaster: args.tx_broadcaster,
31983192

31993193
latest_block_height: AtomicUsize::new(latest_block_height as usize),

src/ln/functional_test_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,7 @@ pub fn create_network(node_count: usize, node_config: &[Option<UserConfig>]) ->
846846
let mut default_config = UserConfig::new();
847847
default_config.channel_options.announced_channel = true;
848848
default_config.peer_channel_config_limits.force_announced_channel_preference = false;
849-
let node = ChannelManager::new(Network::Testnet, feeest.clone(), chan_monitor.clone(), chain_monitor.clone(), tx_broadcaster.clone(), Arc::clone(&logger), keys_manager.clone(), if node_config[i].is_some() { node_config[i].clone().unwrap() } else { default_config }).unwrap();
849+
let node = ChannelManager::new(Network::Testnet, feeest.clone(), chan_monitor.clone(), tx_broadcaster.clone(), Arc::clone(&logger), keys_manager.clone(), if node_config[i].is_some() { node_config[i].clone().unwrap() } else { default_config }).unwrap();
850850
let weak_res = Arc::downgrade(&node);
851851
block_notifier.register_listener(weak_res);
852852
let router = Router::new(PublicKey::from_secret_key(&secp_ctx, &keys_manager.get_node_secret()), chain_monitor.clone(), Arc::clone(&logger));

src/ln/functional_tests.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//! claim outputs on-chain.
44
55
use chain::transaction::OutPoint;
6-
use chain::chaininterface::{ChainListener, ChainWatchInterface, ChainWatchInterfaceUtil};
6+
use chain::chaininterface::{ChainListener, ChainWatchInterfaceUtil};
77
use chain::keysinterface::{KeysInterface, SpendableOutputDescriptor, KeysManager};
88
use chain::keysinterface;
99
use ln::channel::{COMMITMENT_TX_BASE_WEIGHT, COMMITMENT_TX_WEIGHT_PER_HTLC};
@@ -3300,7 +3300,6 @@ fn test_no_txn_manager_serialize_deserialize() {
33003300
keys_manager,
33013301
fee_estimator: Arc::new(test_utils::TestFeeEstimator { sat_per_kw: 253 }),
33023302
monitor: nodes[0].chan_monitor.clone(),
3303-
chain_monitor: nodes[0].chain_monitor.clone(),
33043303
tx_broadcaster: nodes[0].tx_broadcaster.clone(),
33053304
logger: Arc::new(test_utils::TestLogger::new()),
33063305
channel_monitors: &channel_monitors,
@@ -3365,7 +3364,6 @@ fn test_simple_manager_serialize_deserialize() {
33653364
keys_manager,
33663365
fee_estimator: Arc::new(test_utils::TestFeeEstimator { sat_per_kw: 253 }),
33673366
monitor: nodes[0].chan_monitor.clone(),
3368-
chain_monitor: nodes[0].chain_monitor.clone(),
33693367
tx_broadcaster: nodes[0].tx_broadcaster.clone(),
33703368
logger: Arc::new(test_utils::TestLogger::new()),
33713369
channel_monitors: &channel_monitors,
@@ -3426,7 +3424,6 @@ fn test_manager_serialize_deserialize_inconsistent_monitor() {
34263424
keys_manager,
34273425
fee_estimator: Arc::new(test_utils::TestFeeEstimator { sat_per_kw: 253 }),
34283426
monitor: nodes[0].chan_monitor.clone(),
3429-
chain_monitor: nodes[0].chain_monitor.clone(),
34303427
tx_broadcaster: nodes[0].tx_broadcaster.clone(),
34313428
logger: Arc::new(test_utils::TestLogger::new()),
34323429
channel_monitors: &node_0_monitors.iter().map(|monitor| { (monitor.get_funding_txo().unwrap(), monitor) }).collect(),
@@ -6037,7 +6034,6 @@ fn test_data_loss_protect() {
60376034
keys_manager: Arc::new(keysinterface::KeysManager::new(&nodes[0].node_seed, Network::Testnet, Arc::clone(&logger), 42, 21)),
60386035
fee_estimator: feeest.clone(),
60396036
monitor: monitor.clone(),
6040-
chain_monitor: chain_monitor.clone(),
60416037
logger: Arc::clone(&logger),
60426038
tx_broadcaster,
60436039
default_config: UserConfig::new(),

0 commit comments

Comments
 (0)