multi: rename lnwire.NodeAnnouncement
In preparation for adding a NodeAnnouncement2 struct along with a NodeAnnouncement interface, this commit renames the existing NodeAnnouncment struct to NodeAnnouncement1.
This commit is contained in:
22 files changed
+145
-131
No files matched your search
+5
-5
@@ -22,8 +22,8 @@ type HostAnnouncerConfig struct {
|
||||
LookupHost func(string) (net.Addr, error)
|
||||
|
||||
// AdvertisedIPs is the set of IPs that we've already announced with
|
||||
// our current NodeAnnouncement. This set will be constructed to avoid
|
||||
// unnecessary node NodeAnnouncement updates.
|
||||
// our current NodeAnnouncement1. This set will be constructed to avoid
|
||||
// unnecessary node NodeAnnouncement1 updates.
|
||||
AdvertisedIPs map[string]struct{}
|
||||
|
||||
// AnnounceNewIPs announces a new set of IP addresses for the backing
|
||||
@@ -36,7 +36,7 @@ type HostAnnouncerConfig struct {
|
||||
// HostAnnouncer is a sub-system that allows a user to specify a set of hosts
|
||||
// for lnd that will be continually resolved to notice any IP address changes.
|
||||
// If the target IP address for a host changes, then we'll generate a new
|
||||
// NodeAnnouncement that includes these new IPs.
|
||||
// NodeAnnouncement1 that includes these new IPs.
|
||||
type HostAnnouncer struct {
|
||||
cfg HostAnnouncerConfig
|
||||
|
||||
@@ -171,7 +171,7 @@ func (h *HostAnnouncer) hostWatcher() {
|
||||
// announcement on disk. It returns the updated node announcement given a set
|
||||
// of updates to be applied to the current node announcement.
|
||||
type NodeAnnUpdater func(modifier ...NodeAnnModifier,
|
||||
) (lnwire.NodeAnnouncement, error)
|
||||
) (lnwire.NodeAnnouncement1, error)
|
||||
|
||||
// IPAnnouncer is a factory function that generates a new function that uses
|
||||
// the passed annUpdater function to to announce new IP changes for a given
|
||||
@@ -181,7 +181,7 @@ func IPAnnouncer(annUpdater NodeAnnUpdater) func([]net.Addr,
|
||||
|
||||
return func(newAddrs []net.Addr, oldAddrs map[string]struct{}) error {
|
||||
_, err := annUpdater(func(
|
||||
currentNodeAnn *lnwire.NodeAnnouncement) {
|
||||
currentNodeAnn *lnwire.NodeAnnouncement1) {
|
||||
// To ensure we don't duplicate any addresses, we'll
|
||||
// filter out the same of addresses we should no longer
|
||||
// advertise.
|
||||
|
||||
+19
-17
@@ -16,37 +16,39 @@ import (
|
||||
)
|
||||
|
||||
// NodeAnnModifier is a closure that makes in-place modifications to an
|
||||
// lnwire.NodeAnnouncement.
|
||||
type NodeAnnModifier func(*lnwire.NodeAnnouncement)
|
||||
// lnwire.NodeAnnouncement1.
|
||||
type NodeAnnModifier func(*lnwire.NodeAnnouncement1)
|
||||
|
||||
// NodeAnnSetAlias is a functional option that sets the alias of the
|
||||
// given node announcement.
|
||||
func NodeAnnSetAlias(alias lnwire.NodeAlias) func(*lnwire.NodeAnnouncement) {
|
||||
return func(nodeAnn *lnwire.NodeAnnouncement) {
|
||||
func NodeAnnSetAlias(alias lnwire.NodeAlias) func(*lnwire.NodeAnnouncement1) {
|
||||
return func(nodeAnn *lnwire.NodeAnnouncement1) {
|
||||
nodeAnn.Alias = alias
|
||||
}
|
||||
}
|
||||
|
||||
// NodeAnnSetAddrs is a functional option that allows updating the addresses of
|
||||
// the given node announcement.
|
||||
func NodeAnnSetAddrs(addrs []net.Addr) func(*lnwire.NodeAnnouncement) {
|
||||
return func(nodeAnn *lnwire.NodeAnnouncement) {
|
||||
func NodeAnnSetAddrs(addrs []net.Addr) func(*lnwire.NodeAnnouncement1) {
|
||||
return func(nodeAnn *lnwire.NodeAnnouncement1) {
|
||||
nodeAnn.Addresses = addrs
|
||||
}
|
||||
}
|
||||
|
||||
// NodeAnnSetColor is a functional option that sets the color of the
|
||||
// given node announcement.
|
||||
func NodeAnnSetColor(newColor color.RGBA) func(*lnwire.NodeAnnouncement) {
|
||||
return func(nodeAnn *lnwire.NodeAnnouncement) {
|
||||
func NodeAnnSetColor(newColor color.RGBA) func(*lnwire.NodeAnnouncement1) {
|
||||
return func(nodeAnn *lnwire.NodeAnnouncement1) {
|
||||
nodeAnn.RGBColor = newColor
|
||||
}
|
||||
}
|
||||
|
||||
// NodeAnnSetFeatures is a functional option that allows updating the features of
|
||||
// the given node announcement.
|
||||
func NodeAnnSetFeatures(features *lnwire.RawFeatureVector) func(*lnwire.NodeAnnouncement) {
|
||||
return func(nodeAnn *lnwire.NodeAnnouncement) {
|
||||
func NodeAnnSetFeatures(
|
||||
features *lnwire.RawFeatureVector) func(*lnwire.NodeAnnouncement1) {
|
||||
|
||||
return func(nodeAnn *lnwire.NodeAnnouncement1) {
|
||||
nodeAnn.Features = features
|
||||
}
|
||||
}
|
||||
@@ -54,7 +56,7 @@ func NodeAnnSetFeatures(features *lnwire.RawFeatureVector) func(*lnwire.NodeAnno
|
||||
// NodeAnnSetTimestamp is a functional option that sets the timestamp of the
|
||||
// announcement to the current time, or increments it if the timestamp is
|
||||
// already in the future.
|
||||
func NodeAnnSetTimestamp(nodeAnn *lnwire.NodeAnnouncement) {
|
||||
func NodeAnnSetTimestamp(nodeAnn *lnwire.NodeAnnouncement1) {
|
||||
newTimestamp := uint32(time.Now().Unix())
|
||||
if newTimestamp <= nodeAnn.Timestamp {
|
||||
// Increment the prior value to ensure the timestamp
|
||||
@@ -65,11 +67,11 @@ func NodeAnnSetTimestamp(nodeAnn *lnwire.NodeAnnouncement) {
|
||||
nodeAnn.Timestamp = newTimestamp
|
||||
}
|
||||
|
||||
// SignNodeAnnouncement signs the lnwire.NodeAnnouncement provided, which
|
||||
// SignNodeAnnouncement signs the lnwire.NodeAnnouncement1 provided, which
|
||||
// should be the most recent, valid update, otherwise the timestamp may not
|
||||
// monotonically increase from the prior.
|
||||
func SignNodeAnnouncement(signer lnwallet.MessageSigner,
|
||||
keyLoc keychain.KeyLocator, nodeAnn *lnwire.NodeAnnouncement) error {
|
||||
keyLoc keychain.KeyLocator, nodeAnn *lnwire.NodeAnnouncement1) error {
|
||||
|
||||
// Create the DER-encoded ECDSA signature over the message digest.
|
||||
sig, err := SignAnnouncement(signer, keyLoc, nodeAnn)
|
||||
@@ -83,7 +85,7 @@ func SignNodeAnnouncement(signer lnwallet.MessageSigner,
|
||||
}
|
||||
|
||||
// ValidateNodeAnn validates the fields and signature of a node announcement.
|
||||
func ValidateNodeAnn(a *lnwire.NodeAnnouncement) error {
|
||||
func ValidateNodeAnn(a *lnwire.NodeAnnouncement1) error {
|
||||
err := ValidateNodeAnnFields(a)
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid node announcement fields: %w", err)
|
||||
@@ -93,7 +95,7 @@ func ValidateNodeAnn(a *lnwire.NodeAnnouncement) error {
|
||||
}
|
||||
|
||||
// ValidateNodeAnnFields validates the fields of a node announcement.
|
||||
func ValidateNodeAnnFields(a *lnwire.NodeAnnouncement) error {
|
||||
func ValidateNodeAnnFields(a *lnwire.NodeAnnouncement1) error {
|
||||
// Check that it only has at most one DNS address.
|
||||
hasDNSAddr := false
|
||||
for _, addr := range a.Addresses {
|
||||
@@ -120,7 +122,7 @@ func ValidateNodeAnnFields(a *lnwire.NodeAnnouncement) error {
|
||||
// ValidateNodeAnnSignature validates the node announcement by ensuring that the
|
||||
// attached signature is needed a signature of the node announcement under the
|
||||
// specified node public key.
|
||||
func ValidateNodeAnnSignature(a *lnwire.NodeAnnouncement) error {
|
||||
func ValidateNodeAnnSignature(a *lnwire.NodeAnnouncement1) error {
|
||||
// Reconstruct the data of announcement which should be covered by the
|
||||
// signature so we can verify the signature shortly below
|
||||
data, err := a.DataToSign()
|
||||
@@ -146,7 +148,7 @@ func ValidateNodeAnnSignature(a *lnwire.NodeAnnouncement) error {
|
||||
return err
|
||||
}
|
||||
|
||||
return fmt.Errorf("signature on NodeAnnouncement(%x) is "+
|
||||
return fmt.Errorf("signature on NodeAnnouncement1(%x) is "+
|
||||
"invalid: %x", nodeKey.SerializeCompressed(),
|
||||
msgBuf.Bytes())
|
||||
}
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ func SignAnnouncement(signer lnwallet.MessageSigner, keyLoc keychain.KeyLocator,
|
||||
data, err = m.DataToSign()
|
||||
case *lnwire.ChannelUpdate1:
|
||||
data, err = m.DataToSign()
|
||||
case *lnwire.NodeAnnouncement:
|
||||
case *lnwire.NodeAnnouncement1:
|
||||
data, err = m.DataToSign()
|
||||
default:
|
||||
return nil, fmt.Errorf("can't sign %T message", m)
|
||||
|
||||
Reference in new issue
Block a user