diff --git a/channeldb/migration25/channel.go b/channeldb/migration25/channel.go index f33e87955..f825e83cb 100644 --- a/channeldb/migration25/channel.go +++ b/channeldb/migration25/channel.go @@ -277,9 +277,13 @@ type OpenChannel struct { // ChanType denotes which type of channel this is. ChanType ChannelType - // chanStatus is the current status of this channel. If it is not in + // ChanStatus is the current status of this channel. If it is not in // the state Default, it should not be used for forwarding payments. - chanStatus ChannelStatus + // + // NOTE: In `channeldb.OpenChannel`, this field is private. We choose + // to export this private field such that following migrations can + // access this field directly. + ChanStatus ChannelStatus // InitialLocalBalance is the balance we have during the channel // opening. When we are not the initiator, this value represents the @@ -320,10 +324,10 @@ func (c *OpenChannel) hasChanStatus(status ChannelStatus) bool { // Special case ChanStatusDefualt since it isn't actually flag, but a // particular combination (or lack-there-of) of flags. if status == ChanStatusDefault { - return c.chanStatus == ChanStatusDefault + return c.ChanStatus == ChanStatusDefault } - return c.chanStatus&status == status + return c.ChanStatus&status == status } // FundingTxPresent returns true if expect the funding transcation to be found @@ -361,7 +365,7 @@ func fetchChanInfo(chanBucket kvdb.RBucket, c *OpenChannel, legacy bool) error { } c.ChanType = ChannelType(chanType) - c.chanStatus = ChannelStatus(chanStatus) + c.ChanStatus = ChannelStatus(chanStatus) // If this is not the legacy format, we need to read the extra two new // fields. @@ -432,7 +436,7 @@ func putChanInfo(chanBucket kvdb.RwBucket, c *OpenChannel, legacy bool) error { if err := mig.WriteElements(&w, mig.ChannelType(c.ChanType), c.ChainHash, c.FundingOutpoint, c.ShortChannelID, c.IsPending, c.IsInitiator, - mig.ChannelStatus(c.chanStatus), c.FundingBroadcastHeight, + mig.ChannelStatus(c.ChanStatus), c.FundingBroadcastHeight, c.NumConfsRequired, c.ChannelFlags, c.IdentityPub, c.Capacity, c.TotalMSatSent, c.TotalMSatReceived, diff --git a/channeldb/migration26/channel.go b/channeldb/migration26/channel.go index f569ec3a1..cff193274 100644 --- a/channeldb/migration26/channel.go +++ b/channeldb/migration26/channel.go @@ -70,10 +70,6 @@ var ( // NOTE: doesn't have the Packager field as it's not used in current migration. type OpenChannel struct { mig25.OpenChannel - - // chanStatus is the current status of this channel. If it is not in - // the state Default, it should not be used for forwarding payments. - chanStatus mig25.ChannelStatus } // FetchChanInfo deserializes the channel info based on the legacy boolean. @@ -104,7 +100,7 @@ func FetchChanInfo(chanBucket kvdb.RBucket, c *OpenChannel, legacy bool) error { } c.ChanType = mig25.ChannelType(chanType) - c.chanStatus = mig25.ChannelStatus(chanStatus) + c.ChanStatus = mig25.ChannelStatus(chanStatus) // If this is the legacy format, we need to read the extra two new // fields. @@ -239,7 +235,7 @@ func PutChanInfo(chanBucket kvdb.RwBucket, c *OpenChannel, legacy bool) error { if err := mig.WriteElements(&w, mig.ChannelType(c.ChanType), c.ChainHash, c.FundingOutpoint, c.ShortChannelID, c.IsPending, c.IsInitiator, - mig.ChannelStatus(c.chanStatus), c.FundingBroadcastHeight, + mig.ChannelStatus(c.ChanStatus), c.FundingBroadcastHeight, c.NumConfsRequired, c.ChannelFlags, c.IdentityPub, c.Capacity, c.TotalMSatSent, c.TotalMSatReceived, diff --git a/channeldb/migration27/channel.go b/channeldb/migration27/channel.go index 95a6505cd..7fd87a0b4 100644 --- a/channeldb/migration27/channel.go +++ b/channeldb/migration27/channel.go @@ -59,10 +59,6 @@ var ( // NOTE: doesn't have the Packager field as it's not used in current migration. type OpenChannel struct { mig26.OpenChannel - - // chanStatus is the current status of this channel. If it is not in - // the state Default, it should not be used for forwarding payments. - chanStatus mig25.ChannelStatus } // FetchChanInfo deserializes the channel info based on the legacy boolean. @@ -90,7 +86,7 @@ func FetchChanInfo(chanBucket kvdb.RBucket, c *OpenChannel, legacy bool) error { } c.ChanType = mig25.ChannelType(chanType) - c.chanStatus = mig25.ChannelStatus(chanStatus) + c.ChanStatus = mig25.ChannelStatus(chanStatus) // For single funder channels that we initiated and have the funding // transaction to, read the funding txn. @@ -182,7 +178,7 @@ func PutChanInfo(chanBucket kvdb.RwBucket, c *OpenChannel, legacy bool) error { if err := mig.WriteElements(&w, mig.ChannelType(c.ChanType), c.ChainHash, c.FundingOutpoint, c.ShortChannelID, c.IsPending, c.IsInitiator, - mig.ChannelStatus(c.chanStatus), c.FundingBroadcastHeight, + mig.ChannelStatus(c.ChanStatus), c.FundingBroadcastHeight, c.NumConfsRequired, c.ChannelFlags, c.IdentityPub, c.Capacity, c.TotalMSatSent, c.TotalMSatReceived,