diff --git a/cached_addr_book.go b/cached_addr_book.go index 88ca98d..96e1dd3 100644 --- a/cached_addr_book.go +++ b/cached_addr_book.go @@ -65,11 +65,9 @@ const ( ) type peerState struct { - lastConnTime time.Time // last time we successfully connected to this peer - lastConnAddr ma.Multiaddr // last address we connected to this peer on - returnCount int // number of times we've returned this peer from the cache - lastReturnTime time.Time // last time we returned this peer from the cache - connectFailures int // number of times we've failed to connect to this peer + lastConnTime time.Time // last time we successfully connected to this peer + returnCount int // number of times we've returned this peer from the cache + connectFailures int // number of times we've failed to connect to this peer } type cachedAddrBook struct { @@ -140,7 +138,6 @@ func (cab *cachedAddrBook) background(ctx context.Context, host host.Host) { peerStateSize.Set(float64(len(cab.peers))) } pState.lastConnTime = time.Now() - pState.lastConnAddr = ev.Conn.RemoteMultiaddr() pState.connectFailures = 0 // reset connect failures on successful connection cab.mu.Unlock() @@ -265,7 +262,6 @@ func (cab *cachedAddrBook) GetCachedAddrs(p *peer.ID) []types.Multiaddr { peerStateSize.Set(float64(len(cab.peers))) } cab.peers[*p].returnCount++ - cab.peers[*p].lastReturnTime = time.Now() cab.mu.Unlock() var result []types.Multiaddr // convert to local Multiaddr type 🙃 diff --git a/cached_addr_book_test.go b/cached_addr_book_test.go index a90682f..f64216a 100644 --- a/cached_addr_book_test.go +++ b/cached_addr_book_test.go @@ -45,7 +45,6 @@ func TestGetCachedAddrs(t *testing.T) { // Verify return count and time were updated assert.Equal(t, 1, cab.peers[testPeer].returnCount) - assert.False(t, cab.peers[testPeer].lastReturnTime.IsZero()) } func TestBackground(t *testing.T) { @@ -122,7 +121,6 @@ func TestBackground(t *testing.T) { peerState, exists := cab.peers[testPeer] assert.True(t, exists) assert.NotNil(t, peerState) - assert.Equal(t, addr, peerState.lastConnAddr) cab.mu.RUnlock() }