Skip to content

Commit

Permalink
Fix addr expiration
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelangel-nubla committed Jan 2, 2025
1 parent e7d1db1 commit 0d02bc2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion addr.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (a *Addr) resetTimers(resetExpirationTime bool) {
}
}

func (a *Addr) IsStillValid() bool {
func (a *Addr) Valid() bool {
return a.expirationTime.After(time.Now())
}

Expand Down
13 changes: 13 additions & 0 deletions addr_collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,19 @@ func (c *AddrCollection) Filter4() *AddrCollection {
return result
}

func (c *AddrCollection) FilterValid() *AddrCollection {
c.addressesMutex.RLock()
defer c.addressesMutex.RUnlock()

result := NewAddrCollection()
for _, addr := range c.addresses {
if addr.Valid() {
result.Enlist(addr)
}
}
return result
}

func (c *AddrCollection) Get() []*Addr {
c.addressesMutex.RLock()
defer c.addressesMutex.RUnlock()
Expand Down

0 comments on commit 0d02bc2

Please sign in to comment.