From 1b10db212e5a0101181c06b3726034928359e58f Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Mon, 17 Apr 2017 16:20:15 -0700 Subject: [PATCH] lnwire: rename ChannelUpdateAnnouncement to ChannelUpdate --- ...date_announcement.go => channel_update.go} | 44 +++++++++---------- ...ncement_test.go => channel_update_test.go} | 8 ++-- 2 files changed, 26 insertions(+), 26 deletions(-) rename lnwire/{channel_update_announcement.go => channel_update.go} (71%) rename lnwire/{channel_update_announcement_test.go => channel_update_test.go} (84%) diff --git a/lnwire/channel_update_announcement.go b/lnwire/channel_update.go similarity index 71% rename from lnwire/channel_update_announcement.go rename to lnwire/channel_update.go index e10ee629b..0e4a6d7b1 100644 --- a/lnwire/channel_update_announcement.go +++ b/lnwire/channel_update.go @@ -8,11 +8,11 @@ import ( "github.com/roasbeef/btcd/btcec" ) -// ChannelUpdateAnnouncement message is used after channel has been initially -// announced. Each side independently announces its fees and minimum expiry for -// HTLCs and other parameters. Also this message is used to redeclare initially -// setted channel parameters. -type ChannelUpdateAnnouncement struct { +// ChannelUpdate message is used after channel has been initially announced. +// Each side independently announces its fees and minimum expiry for HTLCs and +// other parameters. Also this message is used to redeclare initially setted +// channel parameters. +type ChannelUpdate struct { // Signature is used to validate the announced data and prove the // ownership of node id. Signature *btcec.Signature @@ -47,15 +47,15 @@ type ChannelUpdateAnnouncement struct { FeeProportionalMillionths uint32 } -// A compile time check to ensure ChannelUpdateAnnouncement implements the -// lnwire.Message interface. -var _ Message = (*ChannelUpdateAnnouncement)(nil) +// A compile time check to ensure ChannelUpdate implements the lnwire.Message +// interface. +var _ Message = (*ChannelUpdate)(nil) // Validate performs any necessary sanity checks to ensure all fields present -// on the ChannelUpdateAnnouncement are valid. +// on the ChannelUpdate are valid. // // This is part of the lnwire.Message interface. -func (a *ChannelUpdateAnnouncement) Validate() error { +func (a *ChannelUpdate) Validate() error { // NOTE: As far as we don't have the node id (public key) in this // message, we can't validate the signature on this stage, it should // be validated latter - in discovery service handler. @@ -67,11 +67,11 @@ func (a *ChannelUpdateAnnouncement) Validate() error { return nil } -// Decode deserializes a serialized ChannelUpdateAnnouncement stored in the -// passed io.Reader observing the specified protocol version. +// Decode deserializes a serialized ChannelUpdate stored in the passed +// io.Reader observing the specified protocol version. // // This is part of the lnwire.Message interface. -func (a *ChannelUpdateAnnouncement) Decode(r io.Reader, pver uint32) error { +func (a *ChannelUpdate) Decode(r io.Reader, pver uint32) error { return readElements(r, &a.Signature, &a.ShortChannelID, @@ -84,11 +84,11 @@ func (a *ChannelUpdateAnnouncement) Decode(r io.Reader, pver uint32) error { ) } -// Encode serializes the target ChannelUpdateAnnouncement into the passed -// io.Writer observing the protocol version specified. +// Encode serializes the target ChannelUpdate into the passed io.Writer +// observing the protocol version specified. // // This is part of the lnwire.Message interface. -func (a *ChannelUpdateAnnouncement) Encode(w io.Writer, pver uint32) error { +func (a *ChannelUpdate) Encode(w io.Writer, pver uint32) error { return writeElements(w, a.Signature, a.ShortChannelID, @@ -105,15 +105,15 @@ func (a *ChannelUpdateAnnouncement) Encode(w io.Writer, pver uint32) error { // wire. // // This is part of the lnwire.Message interface. -func (a *ChannelUpdateAnnouncement) Command() uint32 { - return CmdChannelUpdateAnnouncement +func (a *ChannelUpdate) Command() uint32 { + return CmdChannelUpdate } // MaxPayloadLength returns the maximum allowed payload size for this message // observing the specified protocol version. // // This is part of the lnwire.Message interface. -func (a *ChannelUpdateAnnouncement) MaxPayloadLength(pver uint32) uint32 { +func (a *ChannelUpdate) MaxPayloadLength(pver uint32) uint32 { var length uint32 // Signature - 64 bytes @@ -143,9 +143,9 @@ func (a *ChannelUpdateAnnouncement) MaxPayloadLength(pver uint32) uint32 { return length } -// DataToSign is used to retrieve part of the announcement message which -// should be signed. -func (a *ChannelUpdateAnnouncement) DataToSign() ([]byte, error) { +// DataToSign is used to retrieve part of the announcement message which should +// be signed. +func (a *ChannelUpdate) DataToSign() ([]byte, error) { // We should not include the signatures itself. var w bytes.Buffer diff --git a/lnwire/channel_update_announcement_test.go b/lnwire/channel_update_test.go similarity index 84% rename from lnwire/channel_update_announcement_test.go rename to lnwire/channel_update_test.go index eea9c30ea..51b16c0b0 100644 --- a/lnwire/channel_update_announcement_test.go +++ b/lnwire/channel_update_test.go @@ -6,8 +6,8 @@ import ( "testing" ) -func TestChannelUpdateAnnouncementEncodeDecode(t *testing.T) { - cua := &ChannelUpdateAnnouncement{ +func TestChannelUpdateEncodeDecode(t *testing.T) { + cua := &ChannelUpdate{ Signature: someSig, ShortChannelID: someShortChannelID, Timestamp: maxUint32, @@ -21,7 +21,7 @@ func TestChannelUpdateAnnouncementEncodeDecode(t *testing.T) { // Next encode the CUA message into an empty bytes buffer. var b bytes.Buffer if err := cua.Encode(&b, 0); err != nil { - t.Fatalf("unable to encode ChannelUpdateAnnouncement: %v", err) + t.Fatalf("unable to encode ChannelUpdate: %v", err) } // Ensure the max payload estimate is correct. @@ -32,7 +32,7 @@ func TestChannelUpdateAnnouncementEncodeDecode(t *testing.T) { } // Deserialize the encoded CUA message into a new empty struct. - cua2 := &ChannelUpdateAnnouncement{} + cua2 := &ChannelUpdate{} if err := cua2.Decode(&b, 0); err != nil { t.Fatalf("unable to decode ChannelUpdateAnnouncement: %v", err) }