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:
Olaoluwa Osuntokun
2019-01-04 14:59:04 -08:00
parent 821de3e107
commit 4fd1f832d7
2 changed files with 3 additions and 45 deletions

View File

@@ -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,