]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Return a ChannelManager instead of result from ChannelManager::new()
authorMatt Corallo <git@bluematt.me>
Tue, 12 May 2020 17:34:00 +0000 (13:34 -0400)
committerMatt Corallo <git@bluematt.me>
Fri, 22 May 2020 18:28:56 +0000 (14:28 -0400)
We never actually fail, so we can just drop the Result type.

fuzz/src/chanmon_consistency.rs
fuzz/src/full_stack.rs
lightning/src/ln/channelmanager.rs
lightning/src/ln/functional_test_utils.rs

index 9dea831e013c49936954b9126ce80b67ec0a3294..3a236cdfb46ea03ff7c5e4dd47ebc3950668d42b 100644 (file)
@@ -197,7 +197,7 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
                        config.channel_options.fee_proportional_millionths = 0;
                        config.channel_options.announced_channel = true;
                        config.peer_channel_config_limits.min_dust_limit_satoshis = 0;
-                       (Arc::new(ChannelManager::new(Network::Bitcoin, fee_est.clone(), monitor.clone(), broadcast.clone(), Arc::clone(&logger), keys_manager.clone(), config, 0).unwrap()),
+                       (Arc::new(ChannelManager::new(Network::Bitcoin, fee_est.clone(), monitor.clone(), broadcast.clone(), Arc::clone(&logger), keys_manager.clone(), config, 0)),
                        monitor)
                } }
        }
index b2ef709330d02e306e0ba7d675a23d299c356ab8..d8053e48f52f94604bbe16e8455a2718a72c80df 100644 (file)
@@ -339,7 +339,7 @@ pub fn do_test(data: &[u8], logger: &Arc<dyn Logger>) {
        config.channel_options.fee_proportional_millionths =  slice_to_be32(get_slice!(4));
        config.channel_options.announced_channel = get_slice!(1)[0] != 0;
        config.peer_channel_config_limits.min_dust_limit_satoshis = 0;
-       let channelmanager = Arc::new(ChannelManager::new(Network::Bitcoin, fee_est.clone(), monitor.clone(), broadcast.clone(), Arc::clone(&logger), keys_manager.clone(), config, 0).unwrap());
+       let channelmanager = Arc::new(ChannelManager::new(Network::Bitcoin, fee_est.clone(), monitor.clone(), broadcast.clone(), Arc::clone(&logger), keys_manager.clone(), config, 0));
        let our_id = PublicKey::from_secret_key(&Secp256k1::signing_only(), &keys_manager.get_node_secret());
        let net_graph_msg_handler = Arc::new(NetGraphMsgHandler::new(watch.clone(), Arc::clone(&logger)));
 
index d1004bcef3d015037801831e04b52d7ca03a7422..3b17813749bde04fbeb9207d67be2ffbe7dce298 100644 (file)
@@ -707,10 +707,10 @@ impl<ChanSigner: ChannelKeys, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref>
        /// the ChannelManager as a listener to the BlockNotifier and call the BlockNotifier's
        /// `block_(dis)connected` methods, which will notify all registered listeners in one
        /// go.
-       pub fn new(network: Network, fee_est: F, monitor: M, tx_broadcaster: T, logger: L, keys_manager: K, config: UserConfig, current_blockchain_height: usize) -> Result<ChannelManager<ChanSigner, M, T, K, F, L>, secp256k1::Error> {
+       pub fn new(network: Network, fee_est: F, monitor: M, tx_broadcaster: T, logger: L, keys_manager: K, config: UserConfig, current_blockchain_height: usize) -> Self {
                let secp_ctx = Secp256k1::new();
 
-               let res = ChannelManager {
+               ChannelManager {
                        default_configuration: config.clone(),
                        genesis_hash: genesis_block(network).header.bitcoin_hash(),
                        fee_estimator: fee_est,
@@ -740,9 +740,7 @@ impl<ChanSigner: ChannelKeys, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref>
                        keys_manager,
 
                        logger,
-               };
-
-               Ok(res)
+               }
        }
 
        /// Creates a new outbound channel to the given remote node and with the given value.
index 68268316f09581dc231843c1ce919edf368dbb3a..bed83a925cb3e893df9b507b3906c6b608614454 100644 (file)
@@ -1091,7 +1091,7 @@ pub fn create_node_chanmgrs<'a, 'b>(node_count: usize, cfgs: &'a Vec<NodeCfg<'b>
                default_config.channel_options.announced_channel = true;
                default_config.peer_channel_config_limits.force_announced_channel_preference = false;
                default_config.own_channel_config.our_htlc_minimum_msat = 1000; // sanitization being done by the sender, to exerce receiver logic we need to lift of limit
-               let node = ChannelManager::new(Network::Testnet, cfgs[i].fee_estimator, &cfgs[i].chan_monitor, cfgs[i].tx_broadcaster, cfgs[i].logger.clone(), &cfgs[i].keys_manager, if node_config[i].is_some() { node_config[i].clone().unwrap() } else { default_config }, 0).unwrap();
+               let node = ChannelManager::new(Network::Testnet, cfgs[i].fee_estimator, &cfgs[i].chan_monitor, cfgs[i].tx_broadcaster, cfgs[i].logger.clone(), &cfgs[i].keys_manager, if node_config[i].is_some() { node_config[i].clone().unwrap() } else { default_config }, 0);
                chanmgrs.push(node);
        }