From 087e22d81798571fbe20ce01aac7007af5ac9010 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Thu, 16 May 2019 17:40:06 -0700 Subject: [PATCH] contractcourt: obtain supplementary HTLC info from the htlcSets Since we no longer have up to date chain actions on disk, we'll use the HTLC sets in memory which contain the necessary information we need to in order to obtain the HTLC amounts. --- contractcourt/channel_arbitrator.go | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/contractcourt/channel_arbitrator.go b/contractcourt/channel_arbitrator.go index 28040961e..b8862a89a 100644 --- a/contractcourt/channel_arbitrator.go +++ b/contractcourt/channel_arbitrator.go @@ -438,18 +438,24 @@ func (c *ChannelArbitrator) relaunchResolvers() error { commitHash := contractResolutions.CommitHash // Reconstruct the htlc outpoints and data from the chain action log. - // The purpose of the constructed htlc map is to supplement to resolvers - // restored from database with extra data. Ideally this data is stored - // as part of the resolver in the log. This is a workaround to prevent a - // db migration. + // The purpose of the constructed htlc map is to supplement to + // resolvers restored from database with extra data. Ideally this data + // is stored as part of the resolver in the log. This is a workaround + // to prevent a db migration. We use all available htlc sets here in + // order to ensure we have complete coverage. htlcMap := make(map[wire.OutPoint]*channeldb.HTLC) - chainActions, err := c.log.FetchChainActions() - if err != nil { - log.Errorf("unable to fetch chain actions: %v", err) - return err - } - for _, htlcs := range chainActions { - for _, htlc := range htlcs { + for _, htlcs := range c.activeHTLCs { + for _, htlc := range htlcs.incomingHTLCs { + htlc := htlc + outpoint := wire.OutPoint{ + Hash: commitHash, + Index: uint32(htlc.OutputIndex), + } + htlcMap[outpoint] = &htlc + } + + for _, htlc := range htlcs.outgoingHTLCs { + htlc := htlc outpoint := wire.OutPoint{ Hash: commitHash, Index: uint32(htlc.OutputIndex),