channeldb: update chanid in-mem during MarkAsOpen

Modifies the MarkAsOpen operation to also update the
ShortChanID and IsPending fields in-memory. Before,
only the on-disk representation was updated, which
may have lead to stale data channel states being
passed in-memory.
This commit is contained in:
Conner Fromknecht 2018-03-27 17:05:22 -07:00
parent 2b00e01c53
commit 9fd73af589
No known key found for this signature in database
GPG Key ID: 39DE78FBE6ACB0EF

@ -538,7 +538,7 @@ func (c *OpenChannel) MarkAsOpen(openLoc lnwire.ShortChannelID) error {
c.Lock()
defer c.Unlock()
return c.Db.Update(func(tx *bolt.Tx) error {
if err := c.Db.Update(func(tx *bolt.Tx) error {
chanBucket, err := updateChanBucket(tx, c.IdentityPub,
&c.FundingOutpoint, c.ChainHash)
if err != nil {
@ -554,7 +554,14 @@ func (c *OpenChannel) MarkAsOpen(openLoc lnwire.ShortChannelID) error {
channel.ShortChanID = openLoc
return putOpenChannel(chanBucket, channel)
})
}); err != nil {
return err
}
c.IsPending = false
c.ShortChanID = openLoc
return nil
}
// MarkBorked marks the event when the channel as reached an irreconcilable