Merge pull request #953 from cfromknecht/mark-open-in-mem
channeldb: update ShortChanID in-mem during MarkAsOpen
This commit is contained in:
commit
41ea771989
@ -538,7 +538,7 @@ func (c *OpenChannel) MarkAsOpen(openLoc lnwire.ShortChannelID) error {
|
|||||||
c.Lock()
|
c.Lock()
|
||||||
defer c.Unlock()
|
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,
|
chanBucket, err := updateChanBucket(tx, c.IdentityPub,
|
||||||
&c.FundingOutpoint, c.ChainHash)
|
&c.FundingOutpoint, c.ChainHash)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -554,7 +554,14 @@ func (c *OpenChannel) MarkAsOpen(openLoc lnwire.ShortChannelID) error {
|
|||||||
channel.ShortChanID = openLoc
|
channel.ShortChanID = openLoc
|
||||||
|
|
||||||
return putOpenChannel(chanBucket, channel)
|
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
|
// MarkBorked marks the event when the channel as reached an irreconcilable
|
||||||
|
@ -684,6 +684,16 @@ func TestFetchPendingChannels(t *testing.T) {
|
|||||||
t.Fatalf("unable to mark channel as open: %v", err)
|
t.Fatalf("unable to mark channel as open: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if pendingChannels[0].IsPending {
|
||||||
|
t.Fatalf("channel marked open should no longer be pending")
|
||||||
|
}
|
||||||
|
|
||||||
|
if pendingChannels[0].ShortChanID != chanOpenLoc {
|
||||||
|
t.Fatalf("channel opening height not updated: expected %v, "+
|
||||||
|
"got %v", spew.Sdump(pendingChannels[0].ShortChanID),
|
||||||
|
chanOpenLoc)
|
||||||
|
}
|
||||||
|
|
||||||
// Next, we'll re-fetch the channel to ensure that the open height was
|
// Next, we'll re-fetch the channel to ensure that the open height was
|
||||||
// properly set.
|
// properly set.
|
||||||
openChans, err := cdb.FetchAllChannels()
|
openChans, err := cdb.FetchAllChannels()
|
||||||
|
Loading…
Reference in New Issue
Block a user