Skip to content

Commit

Permalink
channeldb: also update chanInfo when updating commitment
Browse files Browse the repository at this point in the history
In this commit, we fix an existing bug wherein we failed to update the
channels state once we accepted a new commitment. As a result, after a
state transition, if the channel state was read from disk, values like
TotalMSatSent wouldn’t be properly updated.
  • Loading branch information
Roasbeef committed Nov 11, 2017
1 parent 150ab00 commit 3875754
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion channeldb/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -629,9 +629,19 @@ func (c *OpenChannel) UpdateCommitment(newCommitment *ChannelCommitment) error {
return err
}

if err = putChanInfo(chanBucket, c); err != nil {
return fmt.Errorf("unable to store chan info: %v", err)
}

// With the proper bucket fetched, we'll now write toe latest
// commitment state to dis for the target party.
return putChanCommitment(chanBucket, newCommitment, true)
err = putChanCommitment(chanBucket, newCommitment, true)
if err != nil {
return fmt.Errorf("unable to store chan "+
"revocations: %v", err)
}

return nil
})
if err != nil {
return err
Expand Down

0 comments on commit 3875754

Please sign in to comment.