Skip to content

Commit 05c5c11

Browse files
committed
f rename and fix comment so that it doesnt reference older version of patch
1 parent 7f9ee5a commit 05c5c11

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -926,13 +926,13 @@ pub(crate) const MPP_TIMEOUT_TICKS: u8 = 3;
926926
pub(crate) const IDEMPOTENCY_TIMEOUT_TICKS: u8 = 7;
927927

928928
/// The maximum number of unfunded channels we can have per-peer before we start rejecting new
929-
/// (inbound) ones. The number of peers without funded channels is limited separately in
930-
/// [`MAX_NO_CHANNEL_PEERS`].
929+
/// (inbound) ones. The number of peers with unfunded channels is limited separately in
930+
/// [`MAX_UNFUNDED_CHANNEL_PEERS`].
931931
const MAX_UNFUNDED_CHANS_PER_PEER: usize = 4;
932932

933-
/// The maximum number of peers which we do not have a (funded) channel with. Once we reach this
934-
/// many peers we reject new (inbound) connections.
935-
const MAX_NO_CHANNEL_PEERS: usize = 50;
933+
/// The maximum number of peers from which we will allow pending unfunded channels. Once we reach
934+
/// this many peers we reject new (inbound) channels.
935+
const MAX_UNFUNDED_CHANNEL_PEERS: usize = 50;
936936

937937
/// Information needed for constructing an invoice route hint for this channel.
938938
#[derive(Clone, Debug, PartialEq)]
@@ -4251,15 +4251,14 @@ where
42514251
Ok(())
42524252
}
42534253

4254-
/// Gets the number of peers which match the given filter which have unfunded inbound channels.
4254+
/// Gets the number of peers which match the given filter which do not have any funded,
4255+
/// outbound, or 0-conf channels.
42554256
///
4256-
/// The filter is called for each node and provided with the number of unfunded channels the
4257-
/// node has.
4258-
///
4259-
/// If the peer in question has funded channels, however, zero will be returned.
4260-
fn peers_with_unfunded_channels<Filter>(&self, mut filter: Filter) -> usize
4257+
/// The filter is called for each peer and provided with the number of unfunded, inbound, and
4258+
/// non-0-conf channels we have with the peer.
4259+
fn peers_without_funded_channels<Filter>(&self, mut filter: Filter) -> usize
42614260
where Filter: FnMut(&PublicKey, &PeerState<<SP::Target as SignerProvider>::Signer>, usize) -> bool {
4262-
let mut peers_with_unfunded_channels = 0;
4261+
let mut peers_without_funded_channels = 0;
42634262
let best_block_height = self.best_block.read().unwrap().height();
42644263
{
42654264
let peer_state_lock = self.per_peer_state.read().unwrap();
@@ -4275,11 +4274,11 @@ where
42754274
}
42764275
if !filter(node_id, &*peer, num_unfunded_channels) { continue; }
42774276
if num_unfunded_channels == peer.channel_by_id.len() {
4278-
peers_with_unfunded_channels += 1;
4277+
peers_without_funded_channels += 1;
42794278
}
42804279
}
42814280
}
4282-
return peers_with_unfunded_channels;
4281+
return peers_without_funded_channels;
42834282
}
42844283

42854284
fn internal_open_channel(&self, counterparty_node_id: &PublicKey, msg: &msgs::OpenChannel) -> Result<(), MsgHandleErrInternal> {
@@ -4306,7 +4305,7 @@ where
43064305
// about peers that never open a channel, so we filter by peers that have at least one
43074306
// channel, and then limit the number of those with unfunded channels.
43084307
let mut this_node_unfunded_channels = 0;
4309-
let peers_with_unfunded_channels = self.peers_with_unfunded_channels(
4308+
let peers_without_funded_channels = self.peers_without_funded_channels(
43104309
|node_id, node, unfunded_channels| {
43114310
if node_id == counterparty_node_id {
43124311
this_node_unfunded_channels = unfunded_channels;
@@ -4323,7 +4322,7 @@ where
43234322
// If this peer already has some channels, a new channel won't increase our number of peers
43244323
// with unfunded channels, so as long as we aren't over the maximum number of unfunded
43254324
// channels per-peer we can accept channels from a peer with existing ones.
4326-
if peer_state.channel_by_id.is_empty() && peers_with_unfunded_channels >= MAX_NO_CHANNEL_PEERS {
4325+
if peer_state.channel_by_id.is_empty() && peers_without_funded_channels >= MAX_UNFUNDED_CHANNEL_PEERS {
43274326
return Err(MsgHandleErrInternal::send_err_msg_no_close(
43284327
"Have too many peers with unfunded channels, not accepting new ones".to_owned(),
43294328
msg.temporary_channel_id.clone()));
@@ -6289,14 +6288,14 @@ where
62896288
// disconnected peers, we still let new peers connect, but we'll reject new channels from
62906289
// them.
62916290
let mut this_peer_has_funded_channels = false;
6292-
let connected_peers_with_unfunded_channels = self.peers_with_unfunded_channels(
6291+
let connected_peers_without_funded_channels = self.peers_without_funded_channels(
62936292
|node_id, node, num_unfunded_channels| {
62946293
if node_id == counterparty_node_id && num_unfunded_channels != node.channel_by_id.len() {
62956294
this_peer_has_funded_channels = true;
62966295
}
62976296
node.is_connected
62986297
});
6299-
if inbound && !this_peer_has_funded_channels && connected_peers_with_unfunded_channels >= MAX_NO_CHANNEL_PEERS {
6298+
if inbound && !this_peer_has_funded_channels && connected_peers_without_funded_channels >= MAX_UNFUNDED_CHANNEL_PEERS {
63006299
return Err(());
63016300
}
63026301

0 commit comments

Comments
 (0)