Skip to content
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.

Commit

Permalink
addrmgr: Remove unused param from GetAddress()
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dskloet authored and dajohi committed Mar 24, 2017
1 parent 11faf1d commit c58b757
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion addrmgr/addrmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
10 changes: 5 additions & 5 deletions addrmgr/addrmanager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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

Expand Down Expand Up @@ -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)
}

Expand All @@ -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")
}
Expand All @@ -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")
}
Expand Down
2 changes: 1 addition & 1 deletion server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit c58b757

Please sign in to comment.