@@ -4331,12 +4331,6 @@ where
4331
4331
let mut peer_state_lock = peer_state_mutex_opt. unwrap ( ) . lock ( ) . unwrap ( ) ;
4332
4332
let peer_state = & mut * peer_state_lock;
4333
4333
4334
- let best_block_height = self . best_block . read ( ) . unwrap ( ) . height ( ) ;
4335
- if Self :: unfunded_channel_count ( peer_state, best_block_height) >= MAX_UNFUNDED_CHANS_PER_PEER {
4336
- return Err ( MsgHandleErrInternal :: send_err_msg_no_close (
4337
- format ! ( "Refusing more than {} unfunded channels." , MAX_UNFUNDED_CHANS_PER_PEER ) ,
4338
- msg. temporary_channel_id . clone ( ) ) ) ;
4339
- }
4340
4334
// If this peer already has some channels, a new channel won't increase our number of peers
4341
4335
// with unfunded channels, so as long as we aren't over the maximum number of unfunded
4342
4336
// channels per-peer we can accept channels from a peer with existing ones.
@@ -4346,6 +4340,13 @@ where
4346
4340
msg. temporary_channel_id . clone ( ) ) ) ;
4347
4341
}
4348
4342
4343
+ let best_block_height = self . best_block . read ( ) . unwrap ( ) . height ( ) ;
4344
+ if Self :: unfunded_channel_count ( peer_state, best_block_height) >= MAX_UNFUNDED_CHANS_PER_PEER {
4345
+ return Err ( MsgHandleErrInternal :: send_err_msg_no_close (
4346
+ format ! ( "Refusing more than {} unfunded channels." , MAX_UNFUNDED_CHANS_PER_PEER ) ,
4347
+ msg. temporary_channel_id . clone ( ) ) ) ;
4348
+ }
4349
+
4349
4350
let mut channel = match Channel :: new_from_req ( & self . fee_estimator , & self . entropy_source , & self . signer_provider ,
4350
4351
counterparty_node_id. clone ( ) , & self . channel_type_features ( ) , & peer_state. latest_features , msg, user_channel_id,
4351
4352
& self . default_configuration , best_block_height, & self . logger , outbound_scid_alias)
0 commit comments