lnwire: rename ChannelUpdateAnnouncement to ChannelUpdate

This commit is contained in:
Olaoluwa Osuntokun 2017-04-17 16:20:15 -07:00
parent e947162d97
commit 1b10db212e
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2
2 changed files with 26 additions and 26 deletions

View File

@ -8,11 +8,11 @@ import (
"github.com/roasbeef/btcd/btcec" "github.com/roasbeef/btcd/btcec"
) )
// ChannelUpdateAnnouncement message is used after channel has been initially // ChannelUpdate message is used after channel has been initially announced.
// announced. Each side independently announces its fees and minimum expiry for // Each side independently announces its fees and minimum expiry for HTLCs and
// HTLCs and other parameters. Also this message is used to redeclare initially // other parameters. Also this message is used to redeclare initially setted
// setted channel parameters. // channel parameters.
type ChannelUpdateAnnouncement struct { type ChannelUpdate struct {
// Signature is used to validate the announced data and prove the // Signature is used to validate the announced data and prove the
// ownership of node id. // ownership of node id.
Signature *btcec.Signature Signature *btcec.Signature
@ -47,15 +47,15 @@ type ChannelUpdateAnnouncement struct {
FeeProportionalMillionths uint32 FeeProportionalMillionths uint32
} }
// A compile time check to ensure ChannelUpdateAnnouncement implements the // A compile time check to ensure ChannelUpdate implements the lnwire.Message
// lnwire.Message interface. // interface.
var _ Message = (*ChannelUpdateAnnouncement)(nil) var _ Message = (*ChannelUpdate)(nil)
// Validate performs any necessary sanity checks to ensure all fields present // 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. // 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 // 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 // message, we can't validate the signature on this stage, it should
// be validated latter - in discovery service handler. // be validated latter - in discovery service handler.
@ -67,11 +67,11 @@ func (a *ChannelUpdateAnnouncement) Validate() error {
return nil return nil
} }
// Decode deserializes a serialized ChannelUpdateAnnouncement stored in the // Decode deserializes a serialized ChannelUpdate stored in the passed
// passed io.Reader observing the specified protocol version. // io.Reader observing the specified protocol version.
// //
// This is part of the lnwire.Message interface. // 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, return readElements(r,
&a.Signature, &a.Signature,
&a.ShortChannelID, &a.ShortChannelID,
@ -84,11 +84,11 @@ func (a *ChannelUpdateAnnouncement) Decode(r io.Reader, pver uint32) error {
) )
} }
// Encode serializes the target ChannelUpdateAnnouncement into the passed // Encode serializes the target ChannelUpdate into the passed io.Writer
// io.Writer observing the protocol version specified. // observing the protocol version specified.
// //
// This is part of the lnwire.Message interface. // 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, return writeElements(w,
a.Signature, a.Signature,
a.ShortChannelID, a.ShortChannelID,
@ -105,15 +105,15 @@ func (a *ChannelUpdateAnnouncement) Encode(w io.Writer, pver uint32) error {
// wire. // wire.
// //
// This is part of the lnwire.Message interface. // This is part of the lnwire.Message interface.
func (a *ChannelUpdateAnnouncement) Command() uint32 { func (a *ChannelUpdate) Command() uint32 {
return CmdChannelUpdateAnnouncement return CmdChannelUpdate
} }
// MaxPayloadLength returns the maximum allowed payload size for this message // MaxPayloadLength returns the maximum allowed payload size for this message
// observing the specified protocol version. // observing the specified protocol version.
// //
// This is part of the lnwire.Message interface. // 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 var length uint32
// Signature - 64 bytes // Signature - 64 bytes
@ -143,9 +143,9 @@ func (a *ChannelUpdateAnnouncement) MaxPayloadLength(pver uint32) uint32 {
return length return length
} }
// DataToSign is used to retrieve part of the announcement message which // DataToSign is used to retrieve part of the announcement message which should
// should be signed. // be signed.
func (a *ChannelUpdateAnnouncement) DataToSign() ([]byte, error) { func (a *ChannelUpdate) DataToSign() ([]byte, error) {
// We should not include the signatures itself. // We should not include the signatures itself.
var w bytes.Buffer var w bytes.Buffer

View File

@ -6,8 +6,8 @@ import (
"testing" "testing"
) )
func TestChannelUpdateAnnouncementEncodeDecode(t *testing.T) { func TestChannelUpdateEncodeDecode(t *testing.T) {
cua := &ChannelUpdateAnnouncement{ cua := &ChannelUpdate{
Signature: someSig, Signature: someSig,
ShortChannelID: someShortChannelID, ShortChannelID: someShortChannelID,
Timestamp: maxUint32, Timestamp: maxUint32,
@ -21,7 +21,7 @@ func TestChannelUpdateAnnouncementEncodeDecode(t *testing.T) {
// Next encode the CUA message into an empty bytes buffer. // Next encode the CUA message into an empty bytes buffer.
var b bytes.Buffer var b bytes.Buffer
if err := cua.Encode(&b, 0); err != nil { 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. // 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. // Deserialize the encoded CUA message into a new empty struct.
cua2 := &ChannelUpdateAnnouncement{} cua2 := &ChannelUpdate{}
if err := cua2.Decode(&b, 0); err != nil { if err := cua2.Decode(&b, 0); err != nil {
t.Fatalf("unable to decode ChannelUpdateAnnouncement: %v", err) t.Fatalf("unable to decode ChannelUpdateAnnouncement: %v", err)
} }