lnwire: rename Expiry to TimeLockDelta within ChannelUpdateAnnouncement

This commit modifies the ChannelUpdateAnnouncement to rename the Expiry
variable instead of TimeLockDelta as that is more descriptive of the
purpose of the attribute itself.
This commit is contained in:
Olaoluwa Osuntokun 2017-03-05 22:43:34 -06:00
parent dc5eb8de37
commit 743de45c92
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2
3 changed files with 32 additions and 23 deletions

@ -26,14 +26,16 @@ type ChannelUpdateAnnouncement struct {
Timestamp uint32 Timestamp uint32
// Flags least-significant bit must be set to 0 if the creating node // Flags least-significant bit must be set to 0 if the creating node
// corresponds to the first node in previously sent channel // corresponds to the first node in the previously sent channel
// announcement and 1 otherwise. // announcement and 1 otherwise.
Flags uint16 Flags uint16
// Expiry is the minimum number of blocks this node requires to be // TimeLockDelta is the minimum number of blocks this node requires to
// added to the expiry of HTLCs. This is a security parameter determined // be added to the expiry of HTLCs. This is a security parameter
// by the node operator. // determined by the node operator. This value represents the required
Expiry uint16 // gap between the time locks of the incoming and outgoing HTLC's set
// to this node.
TimeLockDelta uint16
// HtlcMinimumMstat is the minimum HTLC value which will be accepted. // HtlcMinimumMstat is the minimum HTLC value which will be accepted.
HtlcMinimumMstat uint32 HtlcMinimumMstat uint32
@ -58,7 +60,7 @@ func (a *ChannelUpdateAnnouncement) Validate() error {
// 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.
if a.Expiry == 0 { if a.TimeLockDelta == 0 {
return errors.New("expiry should be greater then zero") return errors.New("expiry should be greater then zero")
} }
@ -75,7 +77,7 @@ func (c *ChannelUpdateAnnouncement) Decode(r io.Reader, pver uint32) error {
&c.ChannelID, &c.ChannelID,
&c.Timestamp, &c.Timestamp,
&c.Flags, &c.Flags,
&c.Expiry, &c.TimeLockDelta,
&c.HtlcMinimumMstat, &c.HtlcMinimumMstat,
&c.FeeBaseMstat, &c.FeeBaseMstat,
&c.FeeProportionalMillionths, &c.FeeProportionalMillionths,
@ -97,7 +99,7 @@ func (c *ChannelUpdateAnnouncement) Encode(w io.Writer, pver uint32) error {
c.ChannelID, c.ChannelID,
c.Timestamp, c.Timestamp,
c.Flags, c.Flags,
c.Expiry, c.TimeLockDelta,
c.HtlcMinimumMstat, c.HtlcMinimumMstat,
c.FeeBaseMstat, c.FeeBaseMstat,
c.FeeProportionalMillionths, c.FeeProportionalMillionths,
@ -161,7 +163,7 @@ func (c *ChannelUpdateAnnouncement) DataToSign() ([]byte, error) {
c.ChannelID, c.ChannelID,
c.Timestamp, c.Timestamp,
c.Flags, c.Flags,
c.Expiry, c.TimeLockDelta,
c.HtlcMinimumMstat, c.HtlcMinimumMstat,
c.FeeBaseMstat, c.FeeBaseMstat,
c.FeeProportionalMillionths, c.FeeProportionalMillionths,

@ -12,7 +12,7 @@ func TestChannelUpdateAnnouncementEncodeDecode(t *testing.T) {
ChannelID: someChannelID, ChannelID: someChannelID,
Timestamp: maxUint32, Timestamp: maxUint32,
Flags: maxUint16, Flags: maxUint16,
Expiry: maxUint16, TimeLockDelta: maxUint16,
HtlcMinimumMstat: maxUint32, HtlcMinimumMstat: maxUint32,
FeeBaseMstat: maxUint32, FeeBaseMstat: maxUint32,
FeeProportionalMillionths: maxUint32, FeeProportionalMillionths: maxUint32,

@ -70,29 +70,36 @@ func (a *Alias) Validate() error {
return nil return nil
} }
// NodeAnnouncement message is used to announce the presence of a lightning node // NodeAnnouncement message is used to announce the presence of a Lightning
// and signal that the node is accepting incoming connections. // node and also to signal that the node is accepting incoming connections.
// Each NodeAnnouncement authenticating the advertised information within the
// announcement via a signature using the advertised node pubkey.
type NodeAnnouncement struct { type NodeAnnouncement struct {
// Signature is used to prove the ownership of node id. // Signature is used to prove the ownership of node id.
Signature *btcec.Signature Signature *btcec.Signature
// Timestamp allows ordering in the case of multiple announcements. // Timestamp allows ordering in the case of multiple
// announcements.
Timestamp uint32 Timestamp uint32
// Address includes two specification fields: 'ipv6' and 'port' on which // Address includes two specification fields: 'ipv6' and
// the node is accepting incoming connections. // 'port' on which the node is accepting incoming connections.
Address *net.TCPAddr Address *net.TCPAddr
// NodeID is a public key which is used as node identification. // NodeID is a public key which is used as node
// identification.
NodeID *btcec.PublicKey NodeID *btcec.PublicKey
// RGBColor is used to customize their node's appearance in maps and graphs // RGBColor is used to customize their node's appearance in
// maps and graphs
RGBColor RGB RGBColor RGB
// pad is used to reserve to additional bytes for future usage. // pad is used to reserve to additional bytes for future
// usage.
pad uint16 pad uint16
// Alias is used to customize their node's appearance in maps and graphs // Alias is used to customize their node's appearance in maps
// and graphs
Alias Alias Alias Alias
} }
@ -109,8 +116,8 @@ func (a *NodeAnnouncement) Validate() error {
return nil return nil
} }
// Decode deserializes a serialized NodeAnnouncement stored in the // Decode deserializes a serialized NodeAnnouncement 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 (c *NodeAnnouncement) Decode(r io.Reader, pver uint32) error { func (c *NodeAnnouncement) Decode(r io.Reader, pver uint32) error {
@ -130,8 +137,8 @@ func (c *NodeAnnouncement) Decode(r io.Reader, pver uint32) error {
return nil return nil
} }
// Encode serializes the target NodeAnnouncement into the passed // Encode serializes the target NodeAnnouncement 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 (c *NodeAnnouncement) Encode(w io.Writer, pver uint32) error { func (c *NodeAnnouncement) Encode(w io.Writer, pver uint32) error {