fix: ping result ttl random
This commit is contained in:
parent
80ec307308
commit
a9e7fee369
@ -240,7 +240,6 @@ func (f *FastestFilter) Filter(nodes []Node) []Node {
|
|||||||
|
|
||||||
// get latency with ttl cache
|
// get latency with ttl cache
|
||||||
now := time.Now().Unix()
|
now := time.Now().Unix()
|
||||||
r := rand.New(rand.NewSource(time.Now().UnixNano()))
|
|
||||||
|
|
||||||
var getNodeLatency = func(node Node) int {
|
var getNodeLatency = func(node Node) int {
|
||||||
if f.pingResultTTL[node.ID] < now {
|
if f.pingResultTTL[node.ID] < now {
|
||||||
@ -251,7 +250,8 @@ func (f *FastestFilter) Filter(nodes []Node) []Node {
|
|||||||
// get latency
|
// get latency
|
||||||
go func(node Node) {
|
go func(node Node) {
|
||||||
latency := f.doTcpPing(node.Addr)
|
latency := f.doTcpPing(node.Addr)
|
||||||
ttl := 300 - int64(60*r.Float64())
|
r := rand.New(rand.NewSource(time.Now().UnixNano()))
|
||||||
|
ttl := 300 - int64(120*r.Float64())
|
||||||
|
|
||||||
f.mu.Lock()
|
f.mu.Lock()
|
||||||
f.pingResult[node.ID] = latency
|
f.pingResult[node.ID] = latency
|
||||||
|
Loading…
Reference in New Issue
Block a user