remove route & zone ageing

This commit is contained in:
Josh Deprez 2024-04-15 17:08:53 +10:00
parent 830f0dfde0
commit fd2ab2918b
Signed by: josh
SSH key fingerprint: SHA256:zZji7w1Ilh2RuUpbQcqkLPrqmRwpiCSycbF2EfKm6Kw
2 changed files with 17 additions and 17 deletions

View file

@ -8,7 +8,7 @@ import (
"github.com/sfiera/multitalk/pkg/ddp"
)
const maxRouteAge = 10 * time.Minute // TODO: confirm
// const maxRouteAge = 10 * time.Minute // TODO: confirm
type Route struct {
Extended bool
@ -42,9 +42,9 @@ func (rt *RoutingTable) LookupRoute(network ddp.Network) *Route {
if network < r.NetStart || network > r.NetEnd {
continue
}
if time.Since(r.LastSeen) > maxRouteAge {
continue
}
// if time.Since(r.LastSeen) > maxRouteAge {
// continue
// }
if bestRoute == nil {
bestRoute = r
continue
@ -86,9 +86,9 @@ func (rt *RoutingTable) ValidRoutes() []*Route {
if r.Peer == nil {
continue
}
if time.Since(r.LastSeen) > maxRouteAge {
continue
}
// if time.Since(r.LastSeen) > maxRouteAge {
// continue
// }
valid = append(valid, r)
}
return valid

View file

@ -25,7 +25,7 @@ import (
"github.com/sfiera/multitalk/pkg/ddp"
)
const maxZoneAge = 10 * time.Minute // TODO: confirm
//const maxZoneAge = 10 * time.Minute // TODO: confirm
type Zone struct {
Network ddp.Network
@ -75,9 +75,9 @@ func (zt *ZoneTable) Query(ns []ddp.Network) map[ddp.Network][]string {
zt.mu.Lock()
defer zt.mu.Unlock()
for _, z := range zt.zones {
if time.Since(z.LastSeen) > maxZoneAge {
continue
}
// if time.Since(z.LastSeen) > maxZoneAge {
// continue
// }
if _, ok := slices.BinarySearch(ns, z.Network); ok {
zs[z.Network] = append(zs[z.Network], z.Name)
}
@ -90,9 +90,9 @@ func (zt *ZoneTable) LocalNames() []string {
seen := make(map[string]struct{})
zs := make([]string, 0, len(zt.zones))
for _, z := range zt.zones {
if time.Since(z.LastSeen) > maxZoneAge {
continue
}
// if time.Since(z.LastSeen) > maxZoneAge {
// continue
// }
if !z.Local {
continue
}
@ -114,9 +114,9 @@ func (zt *ZoneTable) AllNames() []string {
seen := make(map[string]struct{})
zs := make([]string, 0, len(zt.zones))
for _, z := range zt.zones {
if time.Since(z.LastSeen) > maxZoneAge {
continue
}
// if time.Since(z.LastSeen) > maxZoneAge {
// continue
// }
if _, s := seen[z.Name]; s {
continue
}