funding: fix itest flake with pending channels
This commit is contained in:
1 file changed
+24
@@ -108,6 +108,11 @@ const (
|
|||||||
// for the funding transaction to be confirmed before forgetting
|
// for the funding transaction to be confirmed before forgetting
|
||||||
// channels that aren't initiated by us. 2016 blocks is ~2 weeks.
|
// channels that aren't initiated by us. 2016 blocks is ~2 weeks.
|
||||||
maxWaitNumBlocksFundingConf = 2016
|
maxWaitNumBlocksFundingConf = 2016
|
||||||
|
|
||||||
|
// pendingChansLimit is the maximum number of pending channels that we
|
||||||
|
// can have. After this point, pending channel opens will start to be
|
||||||
|
// rejected.
|
||||||
|
pendingChansLimit = 1_000
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -1320,6 +1325,25 @@ func (f *Manager) handleFundingOpen(peer lnpeer.Peer,
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ensure that the pendingChansLimit is respected.
|
||||||
|
pendingChans, err := f.cfg.Wallet.Cfg.Database.FetchPendingChannels()
|
||||||
|
if err != nil {
|
||||||
|
f.failFundingFlow(
|
||||||
|
peer, msg.PendingChannelID, err,
|
||||||
|
)
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(pendingChans) > pendingChansLimit {
|
||||||
|
f.failFundingFlow(
|
||||||
|
peer, msg.PendingChannelID,
|
||||||
|
lnwire.ErrMaxPendingChannels,
|
||||||
|
)
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// We'll also reject any requests to create channels until we're fully
|
// We'll also reject any requests to create channels until we're fully
|
||||||
// synced to the network as we won't be able to properly validate the
|
// synced to the network as we won't be able to properly validate the
|
||||||
// confirmation of the funding transaction.
|
// confirmation of the funding transaction.
|
||||||
|
|||||||
Reference in new issue
Block a user