multi/refactor: separate methods for get and set node announcement
In preparation for a more complex function signature for set node announcement, separate get and set so that readonly callers don't need to handle the extra arguments.
This commit is contained in:
10 files changed
+94
-91
No files matched your search
+10
-12
@@ -203,11 +203,14 @@ type Config struct {
|
||||
// notification for when it reconnects.
|
||||
NotifyWhenOffline func(peerPubKey [33]byte) <-chan struct{}
|
||||
|
||||
// SelfNodeAnnouncement is a function that fetches our own current node
|
||||
// announcement, for use when determining whether we should update our
|
||||
// peers about our presence on the network. If the refresh is true, a
|
||||
// new and updated announcement will be returned.
|
||||
SelfNodeAnnouncement func(refresh bool) (lnwire.NodeAnnouncement, error)
|
||||
// FetchSelfAnnouncement retrieves our current node announcement, for
|
||||
// use when determining whether we should update our peers about our
|
||||
// presence in the network.
|
||||
FetchSelfAnnouncement func() lnwire.NodeAnnouncement
|
||||
|
||||
// UpdateSelfAnnouncement produces a new announcement for our node with
|
||||
// an updated timestamp which can be broadcast to our peers.
|
||||
UpdateSelfAnnouncement func() (lnwire.NodeAnnouncement, error)
|
||||
|
||||
// ProofMatureDelta the number of confirmations which is needed before
|
||||
// exchange the channel announcement proofs.
|
||||
@@ -1660,12 +1663,7 @@ func (d *AuthenticatedGossiper) retransmitStaleAnns(now time.Time) error {
|
||||
}
|
||||
|
||||
// We'll also check that our NodeAnnouncement is not too old.
|
||||
currentNodeAnn, err := d.cfg.SelfNodeAnnouncement(false)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to get current node announment: %v",
|
||||
err)
|
||||
}
|
||||
|
||||
currentNodeAnn := d.cfg.FetchSelfAnnouncement()
|
||||
timestamp := time.Unix(int64(currentNodeAnn.Timestamp), 0)
|
||||
timeElapsed := now.Sub(timestamp)
|
||||
|
||||
@@ -1673,7 +1671,7 @@ func (d *AuthenticatedGossiper) retransmitStaleAnns(now time.Time) error {
|
||||
// node announcement, refresh it and resend it.
|
||||
nodeAnnStr := ""
|
||||
if timeElapsed >= d.cfg.RebroadcastInterval {
|
||||
newNodeAnn, err := d.cfg.SelfNodeAnnouncement(true)
|
||||
newNodeAnn, err := d.cfg.UpdateSelfAnnouncement()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to get refreshed node "+
|
||||
"announcement: %v", err)
|
||||
|
||||
Reference in new issue
Block a user