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:
Carla Kirk-Cohen
2023-04-05 10:21:59 +02:00
parent c6263c2fe6
commit 3f9f0ea5d1
10 changed files with 94 additions and 91 deletions

View File

@@ -168,15 +168,18 @@ func (h *HostAnnouncer) hostWatcher() {
// NodeAnnUpdater describes a function that's able to update our current node
// 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(refresh bool, modifier ...NodeAnnModifier,
type NodeAnnUpdater func(modifier ...NodeAnnModifier,
) (lnwire.NodeAnnouncement, 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
// host.
func IPAnnouncer(annUpdater NodeAnnUpdater) func([]net.Addr, map[string]struct{}) error {
func IPAnnouncer(annUpdater NodeAnnUpdater) func([]net.Addr,
map[string]struct{}) error {
return func(newAddrs []net.Addr, oldAddrs map[string]struct{}) error {
_, err := annUpdater(true, func(currentNodeAnn *lnwire.NodeAnnouncement) {
_, err := annUpdater(func(
currentNodeAnn *lnwire.NodeAnnouncement) {
// To ensure we don't duplicate any addresses, we'll
// filter out the same of addresses we should no longer
// advertise.