channeldb: move serialization of outpoint into db txn in CloseChannel
This commit is contained in:
parent
c1c1cabc4e
commit
aeb7cce7c3
@ -571,21 +571,16 @@ func (c *OpenChannel) FindPreviousState(updateNum uint64) (*ChannelDelta, error)
|
||||
// purposes.
|
||||
// TODO(roasbeef): delete on-disk set of HTLCs
|
||||
func (c *OpenChannel) CloseChannel() error {
|
||||
var b bytes.Buffer
|
||||
if err := writeOutpoint(&b, c.ChanID); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return c.Db.Update(func(tx *bolt.Tx) error {
|
||||
// First fetch the top level bucket which stores all data related to
|
||||
// current, active channels.
|
||||
// First fetch the top level bucket which stores all data
|
||||
// related to current, active channels.
|
||||
chanBucket := tx.Bucket(openChannelBucket)
|
||||
if chanBucket == nil {
|
||||
return ErrNoChanDBExists
|
||||
}
|
||||
|
||||
// Within this top level bucket, fetch the bucket dedicated to storing
|
||||
// open channel data specific to the remote node.
|
||||
// Within this top level bucket, fetch the bucket dedicated to
|
||||
// storing open channel data specific to the remote node.
|
||||
nodePub := c.IdentityPub.SerializeCompressed()
|
||||
nodeChanBucket := chanBucket.Bucket(nodePub)
|
||||
if nodeChanBucket == nil {
|
||||
@ -598,6 +593,11 @@ func (c *OpenChannel) CloseChannel() error {
|
||||
return ErrNoActiveChannels
|
||||
}
|
||||
|
||||
var b bytes.Buffer
|
||||
if err := writeOutpoint(&b, c.ChanID); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// If this channel isn't found within the channel index bucket,
|
||||
// then it has already been deleted. So we can exit early as
|
||||
// there isn't any more work for us to do here.
|
||||
|
Loading…
Reference in New Issue
Block a user