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.
This commit is contained in:
Olaoluwa Osuntokun 2019-05-16 17:40:06 -07:00
parent 8a34b1ae88
commit 087e22d817
No known key found for this signature in database
GPG Key ID: CE58F7F8E20FD9A2

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