@@ -18,7 +18,6 @@ import (
1818type Node struct {
1919 // PubKeyBytes is the raw bytes of the public key of the target node.
2020 PubKeyBytes [33 ]byte
21- pubKey * btcec.PublicKey
2221
2322 // HaveNodeAnnouncement indicates whether we received a node
2423 // announcement for this particular node. If true, the remaining fields
@@ -62,67 +61,53 @@ type Node struct {
6261
6362// PubKey is the node's long-term identity public key. This key will be used to
6463// authenticated any advertisements/updates sent by the node.
65- //
66- // NOTE: By having this method to access an attribute, we ensure we only need
67- // to fully deserialize the pubkey if absolutely necessary.
68- func (l * Node ) PubKey () (* btcec.PublicKey , error ) {
69- if l .pubKey != nil {
70- return l .pubKey , nil
71- }
72-
73- key , err := btcec .ParsePubKey (l .PubKeyBytes [:])
74- if err != nil {
75- return nil , err
76- }
77- l .pubKey = key
78-
79- return key , nil
64+ func (n * Node ) PubKey () (* btcec.PublicKey , error ) {
65+ return btcec .ParsePubKey (n .PubKeyBytes [:])
8066}
8167
8268// AuthSig is a signature under the advertised public key which serves to
8369// authenticate the attributes announced by this node.
8470//
8571// NOTE: By having this method to access an attribute, we ensure we only need
8672// to fully deserialize the signature if absolutely necessary.
87- func (l * Node ) AuthSig () (* ecdsa.Signature , error ) {
88- return ecdsa .ParseSignature (l .AuthSigBytes )
73+ func (n * Node ) AuthSig () (* ecdsa.Signature , error ) {
74+ return ecdsa .ParseSignature (n .AuthSigBytes )
8975}
9076
9177// AddPubKey is a setter-link method that can be used to swap out the public
9278// key for a node.
93- func (l * Node ) AddPubKey (key * btcec.PublicKey ) {
94- l .pubKey = key
95- copy (l .PubKeyBytes [:], key .SerializeCompressed ())
79+ func (n * Node ) AddPubKey (key * btcec.PublicKey ) {
80+ copy (n .PubKeyBytes [:], key .SerializeCompressed ())
9681}
9782
9883// NodeAnnouncement retrieves the latest node announcement of the node.
99- func (l * Node ) NodeAnnouncement (signed bool ) (* lnwire.NodeAnnouncement1 ,
84+ func (n * Node ) NodeAnnouncement (signed bool ) (* lnwire.NodeAnnouncement1 ,
10085 error ) {
10186
102- if ! l .HaveNodeAnnouncement {
87+ if ! n .HaveNodeAnnouncement {
10388 return nil , fmt .Errorf ("node does not have node announcement" )
10489 }
10590
106- alias , err := lnwire .NewNodeAlias (l .Alias )
91+ alias , err := lnwire .NewNodeAlias (n .Alias )
10792 if err != nil {
10893 return nil , err
10994 }
11095
11196 nodeAnn := & lnwire.NodeAnnouncement1 {
112- Features : l .Features .RawFeatureVector ,
113- NodeID : l .PubKeyBytes ,
114- RGBColor : l .Color ,
97+ Features : n .Features .RawFeatureVector ,
98+ NodeID : n .PubKeyBytes ,
99+ RGBColor : n .Color ,
115100 Alias : alias ,
116- Addresses : l .Addresses ,
117- Timestamp : uint32 (l .LastUpdate .Unix ()),
118- ExtraOpaqueData : l .ExtraOpaqueData ,
101+ Addresses : n .Addresses ,
102+ Timestamp : uint32 (n .LastUpdate .Unix ()),
103+ ExtraOpaqueData : n .ExtraOpaqueData ,
119104 }
120105
121106 if ! signed {
122107 return nodeAnn , nil
123108 }
124109
125- sig , err := lnwire .NewSigFromECDSARawSignature (l .AuthSigBytes )
110+ sig , err := lnwire .NewSigFromECDSARawSignature (n .AuthSigBytes )
126111 if err != nil {
127112 return nil , err
128113 }
0 commit comments