multi: rename ChannelUpdate to ChannelUpdate1

In preparation for adding a new ChannelUpdate2 message and a
ChannelUpdate interface, we rename the existing message to
ChannelUpdate1.
This commit is contained in:
Elle Mouton
2024-08-21 08:39:37 +02:00
parent bb44efa21f
commit 60f331edb1
43 changed files with 198 additions and 172 deletions

View File

@@ -601,7 +601,7 @@ func (f *FailInvalidOnionKey) Error() string {
// unable to pull out a fully valid version, then we'll fall back to the
// regular parsing mechanism which includes the length prefix an NO type byte.
func parseChannelUpdateCompatibilityMode(reader io.Reader, length uint16,
chanUpdate *ChannelUpdate, pver uint32) error {
chanUpdate *ChannelUpdate1, pver uint32) error {
// Instantiate a LimitReader because there may be additional data
// present after the channel update. Without limiting the stream, the
@@ -648,11 +648,13 @@ type FailTemporaryChannelFailure struct {
// which caused the failure.
//
// NOTE: This field is optional.
Update *ChannelUpdate
Update *ChannelUpdate1
}
// NewTemporaryChannelFailure creates new instance of the FailTemporaryChannelFailure.
func NewTemporaryChannelFailure(update *ChannelUpdate) *FailTemporaryChannelFailure {
func NewTemporaryChannelFailure(
update *ChannelUpdate1) *FailTemporaryChannelFailure {
return &FailTemporaryChannelFailure{Update: update}
}
@@ -686,7 +688,7 @@ func (f *FailTemporaryChannelFailure) Decode(r io.Reader, pver uint32) error {
}
if length != 0 {
f.Update = &ChannelUpdate{}
f.Update = &ChannelUpdate1{}
return parseChannelUpdateCompatibilityMode(
r, length, f.Update, pver,
@@ -721,12 +723,12 @@ type FailAmountBelowMinimum struct {
// Update is used to update information about state of the channel
// which caused the failure.
Update ChannelUpdate
Update ChannelUpdate1
}
// NewAmountBelowMinimum creates new instance of the FailAmountBelowMinimum.
func NewAmountBelowMinimum(htlcMsat MilliSatoshi,
update ChannelUpdate) *FailAmountBelowMinimum {
update ChannelUpdate1) *FailAmountBelowMinimum {
return &FailAmountBelowMinimum{
HtlcMsat: htlcMsat,
@@ -762,7 +764,7 @@ func (f *FailAmountBelowMinimum) Decode(r io.Reader, pver uint32) error {
return err
}
f.Update = ChannelUpdate{}
f.Update = ChannelUpdate1{}
return parseChannelUpdateCompatibilityMode(
r, length, &f.Update, pver,
@@ -791,12 +793,12 @@ type FailFeeInsufficient struct {
// Update is used to update information about state of the channel
// which caused the failure.
Update ChannelUpdate
Update ChannelUpdate1
}
// NewFeeInsufficient creates new instance of the FailFeeInsufficient.
func NewFeeInsufficient(htlcMsat MilliSatoshi,
update ChannelUpdate) *FailFeeInsufficient {
update ChannelUpdate1) *FailFeeInsufficient {
return &FailFeeInsufficient{
HtlcMsat: htlcMsat,
Update: update,
@@ -831,7 +833,7 @@ func (f *FailFeeInsufficient) Decode(r io.Reader, pver uint32) error {
return err
}
f.Update = ChannelUpdate{}
f.Update = ChannelUpdate1{}
return parseChannelUpdateCompatibilityMode(
r, length, &f.Update, pver,
@@ -862,12 +864,12 @@ type FailIncorrectCltvExpiry struct {
// Update is used to update information about state of the channel
// which caused the failure.
Update ChannelUpdate
Update ChannelUpdate1
}
// NewIncorrectCltvExpiry creates new instance of the FailIncorrectCltvExpiry.
func NewIncorrectCltvExpiry(cltvExpiry uint32,
update ChannelUpdate) *FailIncorrectCltvExpiry {
update ChannelUpdate1) *FailIncorrectCltvExpiry {
return &FailIncorrectCltvExpiry{
CltvExpiry: cltvExpiry,
@@ -900,7 +902,7 @@ func (f *FailIncorrectCltvExpiry) Decode(r io.Reader, pver uint32) error {
return err
}
f.Update = ChannelUpdate{}
f.Update = ChannelUpdate1{}
return parseChannelUpdateCompatibilityMode(
r, length, &f.Update, pver,
@@ -925,11 +927,11 @@ func (f *FailIncorrectCltvExpiry) Encode(w *bytes.Buffer, pver uint32) error {
type FailExpiryTooSoon struct {
// Update is used to update information about state of the channel
// which caused the failure.
Update ChannelUpdate
Update ChannelUpdate1
}
// NewExpiryTooSoon creates new instance of the FailExpiryTooSoon.
func NewExpiryTooSoon(update ChannelUpdate) *FailExpiryTooSoon {
func NewExpiryTooSoon(update ChannelUpdate1) *FailExpiryTooSoon {
return &FailExpiryTooSoon{
Update: update,
}
@@ -958,7 +960,7 @@ func (f *FailExpiryTooSoon) Decode(r io.Reader, pver uint32) error {
return err
}
f.Update = ChannelUpdate{}
f.Update = ChannelUpdate1{}
return parseChannelUpdateCompatibilityMode(
r, length, &f.Update, pver,
@@ -984,11 +986,13 @@ type FailChannelDisabled struct {
// Update is used to update information about state of the channel
// which caused the failure.
Update ChannelUpdate
Update ChannelUpdate1
}
// NewChannelDisabled creates new instance of the FailChannelDisabled.
func NewChannelDisabled(flags uint16, update ChannelUpdate) *FailChannelDisabled {
func NewChannelDisabled(flags uint16,
update ChannelUpdate1) *FailChannelDisabled {
return &FailChannelDisabled{
Flags: flags,
Update: update,
@@ -1023,7 +1027,7 @@ func (f *FailChannelDisabled) Decode(r io.Reader, pver uint32) error {
return err
}
f.Update = ChannelUpdate{}
f.Update = ChannelUpdate1{}
return parseChannelUpdateCompatibilityMode(
r, length, &f.Update, pver,
@@ -1516,7 +1520,7 @@ func makeEmptyOnionError(code FailCode) (FailureMessage, error) {
// writeOnionErrorChanUpdate writes out a ChannelUpdate using the onion error
// format. The format is that we first write out the true serialized length of
// the channel update, followed by the serialized channel update itself.
func writeOnionErrorChanUpdate(w *bytes.Buffer, chanUpdate *ChannelUpdate,
func writeOnionErrorChanUpdate(w *bytes.Buffer, chanUpdate *ChannelUpdate1,
pver uint32) error {
// First, we encode the channel update in a temporary buffer in order