From c58b7577e14f3d166f1c8376e3fc4f3742cca8af Mon Sep 17 00:00:00 2001 From: dskloet Date: Mon, 21 Nov 2016 15:56:46 +0100 Subject: [PATCH] addrmgr: Remove unused param from GetAddress() addrmgr.GetAddress() had a parameter `class string` originally intended to support looking up addresses according to some type of filter such as IPv4, IPv6, and only those which support specific wire.ServiceFlags (full nodes, nodes that support bloom filters, nodes that support segwit, etc). But currently the parameter is unused and also has an inappropriate type `string`. If it would ever be used, it's easy to add back and should then get an appropriate type such as something that allows bitflags to be set so that the caller could request combinations such as peers that support IPv6, are full nodes, and support bloom filters. --- addrmgr/addrmanager.go | 2 +- addrmgr/addrmanager_test.go | 10 +++++----- server.go | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/addrmgr/addrmanager.go b/addrmgr/addrmanager.go index fa9de70bc1..0bd18c9d60 100644 --- a/addrmgr/addrmanager.go +++ b/addrmgr/addrmanager.go @@ -744,7 +744,7 @@ func NetAddressKey(na *wire.NetAddress) string { // random one from the possible addresses with preference given to ones that // have not been used recently and should not pick 'close' addresses // consecutively. -func (a *AddrManager) GetAddress(class string) *KnownAddress { +func (a *AddrManager) GetAddress() *KnownAddress { // Protect concurrent access. a.mtx.Lock() defer a.mtx.Unlock() diff --git a/addrmgr/addrmanager_test.go b/addrmgr/addrmanager_test.go index bc1c022f79..e9a1f21d93 100644 --- a/addrmgr/addrmanager_test.go +++ b/addrmgr/addrmanager_test.go @@ -222,7 +222,7 @@ func TestAttempt(t *testing.T) { if err != nil { t.Fatalf("Adding address failed: %v", err) } - ka := n.GetAddress("any") + ka := n.GetAddress() if !ka.LastAttempt().IsZero() { t.Errorf("Address should not have attempts, but does") @@ -244,7 +244,7 @@ func TestConnected(t *testing.T) { if err != nil { t.Fatalf("Adding address failed: %v", err) } - ka := n.GetAddress("any") + ka := n.GetAddress() na := ka.NetAddress() na.Timestamp = time.Now().Add(time.Hour * -1) // make it an hour ago @@ -335,7 +335,7 @@ func TestGetAddress(t *testing.T) { n := addrmgr.New("testgetaddress", lookupFunc) // Get an address from an empty set (should error) - if rv := n.GetAddress("any"); rv != nil { + if rv := n.GetAddress(); rv != nil { t.Errorf("GetAddress failed: got: %v want: %v\n", rv, nil) } @@ -344,7 +344,7 @@ func TestGetAddress(t *testing.T) { if err != nil { t.Fatalf("Adding address failed: %v", err) } - ka := n.GetAddress("any") + ka := n.GetAddress() if ka == nil { t.Fatalf("Did not get an address where there is one in the pool") } @@ -354,7 +354,7 @@ func TestGetAddress(t *testing.T) { // Mark this as a good address and get it n.Good(ka.NetAddress()) - ka = n.GetAddress("any") + ka = n.GetAddress() if ka == nil { t.Fatalf("Did not get an address where there is one in the pool") } diff --git a/server.go b/server.go index a1513b9990..1f08ffcd17 100644 --- a/server.go +++ b/server.go @@ -2400,7 +2400,7 @@ func newServer(listenAddrs []string, db database.DB, chainParams *chaincfg.Param if !cfg.SimNet && len(cfg.ConnectPeers) == 0 { newAddressFunc = func() (net.Addr, error) { for tries := 0; tries < 100; tries++ { - addr := s.addrManager.GetAddress("any") + addr := s.addrManager.GetAddress() if addr == nil { break }