Merge pull request #3763 from joostjager/close-later
cnct: keep open channel data after channel commitment tx confirms
This commit is contained in:
commit
2ce22d912b
@ -37,6 +37,11 @@ var (
|
|||||||
// TODO(roasbeef): flesh out comment
|
// TODO(roasbeef): flesh out comment
|
||||||
openChannelBucket = []byte("open-chan-bucket")
|
openChannelBucket = []byte("open-chan-bucket")
|
||||||
|
|
||||||
|
// historicalChannelBucket stores all channels that have seen their
|
||||||
|
// commitment tx confirm. All information from their previous open state
|
||||||
|
// is retained.
|
||||||
|
historicalChannelBucket = []byte("historical-chan-bucket")
|
||||||
|
|
||||||
// chanInfoKey can be accessed within the bucket for a channel
|
// chanInfoKey can be accessed within the bucket for a channel
|
||||||
// (identified by its chanPoint). This key stores all the static
|
// (identified by its chanPoint). This key stores all the static
|
||||||
// information for a channel which is decided at the end of the
|
// information for a channel which is decided at the end of the
|
||||||
@ -2285,7 +2290,8 @@ func (c *OpenChannel) CloseChannel(summary *ChannelCloseSummary) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
chanBucket := chainBucket.Bucket(chanPointBuf.Bytes())
|
chanKey := chanPointBuf.Bytes()
|
||||||
|
chanBucket := chainBucket.Bucket(chanKey)
|
||||||
if chanBucket == nil {
|
if chanBucket == nil {
|
||||||
return ErrNoActiveChannels
|
return ErrNoActiveChannels
|
||||||
}
|
}
|
||||||
@ -2322,6 +2328,25 @@ func (c *OpenChannel) CloseChannel(summary *ChannelCloseSummary) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add channel state to the historical channel bucket.
|
||||||
|
historicalBucket, err := tx.CreateBucketIfNotExists(
|
||||||
|
historicalChannelBucket,
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
historicalChanBucket, err :=
|
||||||
|
historicalBucket.CreateBucketIfNotExists(chanKey)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = putOpenChannel(historicalChanBucket, chanState)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// Finally, create a summary of this channel in the closed
|
// Finally, create a summary of this channel in the closed
|
||||||
// channel bucket for this node.
|
// channel bucket for this node.
|
||||||
return putChannelCloseSummary(
|
return putChannelCloseSummary(
|
||||||
|
Loading…
Reference in New Issue
Block a user