channeldb: also update chanInfo when updating commitment

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.
This commit is contained in:
Olaoluwa Osuntokun 2017-11-10 19:31:47 -08:00
parent 150ab00842
commit 3875754e0f
No known key found for this signature in database
GPG Key ID: 964EA263DD637C21

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