From e1b2ceca8071dc391a471e9f69154fe1e8c17032 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 b1c32b5e..1f6d869a 100644 --- a/addrmgr/addrmanager.go +++ b/addrmgr/addrmanager.go @@ -739,7 +739,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 c3e5d7b0..c384b015 100644 --- a/addrmgr/addrmanager_test.go +++ b/addrmgr/addrmanager_test.go @@ -221,7 +221,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") @@ -243,7 +243,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 @@ -334,7 +334,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) } @@ -343,7 +343,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") } @@ -353,7 +353,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 5897172f..d832225f 100644 --- a/server.go +++ b/server.go @@ -2411,7 +2411,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 }