mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-28 14:40:51 +02:00
contractcourt+rpc: use new FetchChannel method instead of scanning
In this commit, we modify areas where we need to force close a channel to use the new FetchChannel method instead of manually scanning. This dramatically reduces the CPU usage when doing things like closing a large number of channels within lnd.
This commit is contained in:
@@ -224,23 +224,10 @@ func newActiveChannelArbitrator(channel *channeldb.OpenChannel,
|
||||
// With the channels fetched, attempt to locate
|
||||
// the target channel according to its channel
|
||||
// point.
|
||||
dbChannels, err := c.chanSource.FetchAllChannels()
|
||||
channel, err := c.chanSource.FetchChannel(chanPoint)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var channel *channeldb.OpenChannel
|
||||
for _, dbChannel := range dbChannels {
|
||||
if dbChannel.FundingOutpoint == chanPoint {
|
||||
channel = dbChannel
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// If the channel cannot be located, then we
|
||||
// exit with an error to the channel.
|
||||
if channel == nil {
|
||||
return nil, fmt.Errorf("unable to find channel")
|
||||
}
|
||||
|
||||
chanMachine, err := lnwallet.NewLightningChannel(
|
||||
c.cfg.Signer, c.cfg.PreimageDB, channel, nil,
|
||||
|
Reference in New Issue
Block a user