From da10cb95b5ef32420b8a8bb3fca1fdd86ddacce7 Mon Sep 17 00:00:00 2001 From: Matt Morehouse Date: Tue, 6 Dec 2022 12:28:33 -0600 Subject: [PATCH] contractcourt: fully use chanPoint variable When we create a temporary chanPoint variable to shorten up the code, we should use it everywhere for consistency and clarity. --- contractcourt/chain_arbitrator.go | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/contractcourt/chain_arbitrator.go b/contractcourt/chain_arbitrator.go index de06078e8..ffd26e66a 100644 --- a/contractcourt/chain_arbitrator.go +++ b/contractcourt/chain_arbitrator.go @@ -342,14 +342,13 @@ func (a *arbChannel) ForceCloseChan() (*lnwallet.LocalForceCloseSummary, error) func newActiveChannelArbitrator(channel *channeldb.OpenChannel, c *ChainArbitrator, chanEvents *ChainEventSubscription) (*ChannelArbitrator, error) { - log.Tracef("Creating ChannelArbitrator for ChannelPoint(%v)", - channel.FundingOutpoint) - // TODO(roasbeef): fetch best height (or pass in) so can ensure block // epoch delivers all the notifications to chanPoint := channel.FundingOutpoint + log.Tracef("Creating ChannelArbitrator for ChannelPoint(%v)", chanPoint) + // Next we'll create the matching configuration struct that contains // all interfaces and methods the arbitrator needs to do its job. arbCfg := ChannelArbitratorConfig{ @@ -375,8 +374,7 @@ func newActiveChannelArbitrator(channel *channeldb.OpenChannel, report *channeldb.ResolverReport) error { return c.chanSource.PutResolverReport( - tx, c.cfg.ChainHash, &channel.FundingOutpoint, - report, + tx, c.cfg.ChainHash, &chanPoint, report, ) }, FetchHistoricalChannel: func() (*channeldb.OpenChannel, error) { @@ -1125,12 +1123,13 @@ func (c *ChainArbitrator) WatchNewChannel(newChan *channeldb.OpenChannel) error c.Lock() defer c.Unlock() + chanPoint := newChan.FundingOutpoint + log.Infof("Creating new ChannelArbitrator for ChannelPoint(%v)", - newChan.FundingOutpoint) + chanPoint) // If we're already watching this channel, then we'll ignore this // request. - chanPoint := newChan.FundingOutpoint if _, ok := c.activeChannels[chanPoint]; ok { return nil } @@ -1157,7 +1156,7 @@ func (c *ChainArbitrator) WatchNewChannel(newChan *channeldb.OpenChannel) error return err } - c.activeWatchers[newChan.FundingOutpoint] = chainWatcher + c.activeWatchers[chanPoint] = chainWatcher // We'll also create a new channel arbitrator instance using this new // channel, and our internal state.