Skip to content

Commit 72fa184

Browse files
committed
Add a method to update the current UserConfig in ChannelManager
The `UserConfig` is used to set the default configuration on new channels and also controls some global behavior in `ChannelManager`, so should probably be updatable without restarting the node. Here we add such a method. We also take this opportunity to rename the `UserConfig` related methods and update their docs since `UserConfig` has been more than just the default configuration for new channels for some time. Fixes #2420
1 parent 1bae740 commit 72fa184

File tree

5 files changed

+15
-8
lines changed

5 files changed

+15
-8
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3801,11 +3801,18 @@ where
38013801
}
38023802
}
38033803

3804-
/// Gets the current configuration applied to all new channels.
3805-
pub fn get_current_default_configuration(&self) -> UserConfig {
3804+
/// Gets the current [`UserConfig`] which controls some global behavior and includes the
3805+
/// default configuration applied to all new channels.
3806+
pub fn get_current_config(&self) -> UserConfig {
38063807
self.config.read().unwrap().clone()
38073808
}
38083809

3810+
/// Updates the current [`UserConfig`] which controls some global behavior and includes the
3811+
/// default configuration applied to all new channels.
3812+
pub fn set_current_config(&self, new_config: UserConfig) {
3813+
*self.config.write().unwrap() = new_config;
3814+
}
3815+
38093816
#[cfg(test)]
38103817
pub fn create_and_insert_outbound_scid_alias_for_test(&self) -> u64 {
38113818
self.create_and_insert_outbound_scid_alias()

lightning/src/ln/dual_funding_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ fn do_test_v2_channel_establishment(session: V2ChannelEstablishmentTestSession)
6262
funding_satoshis,
6363
initiator_funding_inputs.clone(),
6464
42, /* user_channel_id */
65-
&nodes[0].node.get_current_default_configuration(),
65+
&nodes[0].node.get_current_config(),
6666
nodes[0].best_block_info().1,
6767
nodes[0].node.create_and_insert_outbound_scid_alias_for_test(),
6868
ConfirmationTarget::NonAnchorChannelFee,

lightning/src/ln/functional_test_utils.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,7 @@ impl<'a, 'b, 'c> Drop for Node<'a, 'b, 'c> {
866866
)>::read(
867867
&mut io::Cursor::new(w.0),
868868
ChannelManagerReadArgs {
869-
config: self.node.get_current_default_configuration(),
869+
config: self.node.get_current_config(),
870870
entropy_source: self.keys_manager,
871871
node_signer: self.keys_manager,
872872
signer_provider: self.keys_manager,
@@ -1651,7 +1651,7 @@ pub fn exchange_open_accept_chan<'a, 'b, 'c>(
16511651
42
16521652
);
16531653
node_b.node.handle_open_channel(node_a_id, &open_channel_msg);
1654-
if node_b.node.get_current_default_configuration().manually_accept_inbound_channels {
1654+
if node_b.node.get_current_config().manually_accept_inbound_channels {
16551655
let events = node_b.node.get_and_clear_pending_events();
16561656
assert_eq!(events.len(), 1);
16571657
match &events[0] {
@@ -1830,7 +1830,7 @@ pub fn create_unannounced_chan_between_nodes_with_value<'a, 'b, 'c, 'd>(
18301830
let node_a_id = nodes[a].node.get_our_node_id();
18311831
let node_b_id = nodes[b].node.get_our_node_id();
18321832

1833-
let mut no_announce_cfg = nodes[a].node.get_current_default_configuration();
1833+
let mut no_announce_cfg = nodes[a].node.get_current_config();
18341834
no_announce_cfg.channel_handshake_config.announce_for_forwarding = false;
18351835
nodes[a]
18361836
.node

lightning/src/ln/onion_route_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1776,7 +1776,7 @@ fn do_test_onion_failure_stale_channel_update(announce_for_forwarding: bool) {
17761776
let chan_2_monitor_serialized = get_monitor!(nodes[1], channel_to_update.0).encode();
17771777
reload_node!(
17781778
nodes[1],
1779-
nodes[1].node.get_current_default_configuration().clone(),
1779+
nodes[1].node.get_current_config(),
17801780
&nodes[1].node.encode(),
17811781
&[&chan_1_monitor_serialized, &chan_2_monitor_serialized],
17821782
persister,

lightning/src/ln/reorg_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ fn do_test_unconf_chan(reload_node: bool, reorg_after_reload: bool, use_funding_
323323
let nodes_0_serialized = nodes[0].node.encode();
324324
let chan_0_monitor_serialized = get_monitor!(nodes[0], chan.2).encode();
325325

326-
reload_node!(nodes[0], nodes[0].node.get_current_default_configuration().clone(), &nodes_0_serialized, &[&chan_0_monitor_serialized], persister, new_chain_monitor, nodes_0_deserialized);
326+
reload_node!(nodes[0], nodes[0].node.get_current_config(), &nodes_0_serialized, &[&chan_0_monitor_serialized], persister, new_chain_monitor, nodes_0_deserialized);
327327
}
328328

329329
if reorg_after_reload {

0 commit comments

Comments
 (0)