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.
This commit is contained in:
dskloet 2016-11-21 15:56:46 +01:00 committed by Dave Collins
parent 7f237aa5e5
commit e1b2ceca80
3 changed files with 7 additions and 7 deletions

View file

@ -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()

View file

@ -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")
}

View file

@ -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
}