Merge pull request #5968 from filcloud/ping-ask
remove duplicate ask and calculate ping before lock
This commit is contained in:
commit
462a44902e
@ -1296,7 +1296,8 @@ var clientListAsksCmd = &cli.Command{
|
|||||||
Usage: "List asks for top miners",
|
Usage: "List asks for top miners",
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
Name: "by-ping",
|
Name: "by-ping",
|
||||||
|
Usage: "sort by ping",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "output-format",
|
Name: "output-format",
|
||||||
@ -1451,17 +1452,17 @@ loop:
|
|||||||
}
|
}
|
||||||
|
|
||||||
rt := time.Now()
|
rt := time.Now()
|
||||||
|
|
||||||
_, err = api.ClientQueryAsk(ctx, *mi.PeerId, miner)
|
_, err = api.ClientQueryAsk(ctx, *mi.PeerId, miner)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
pingDuration := time.Now().Sub(rt)
|
||||||
|
|
||||||
atomic.AddInt64(&got, 1)
|
atomic.AddInt64(&got, 1)
|
||||||
lk.Lock()
|
lk.Lock()
|
||||||
asks = append(asks, QueriedAsk{
|
asks = append(asks, QueriedAsk{
|
||||||
Ask: ask,
|
Ask: ask,
|
||||||
Ping: time.Now().Sub(rt),
|
Ping: pingDuration,
|
||||||
})
|
})
|
||||||
lk.Unlock()
|
lk.Unlock()
|
||||||
}(miner)
|
}(miner)
|
||||||
|
Loading…
Reference in New Issue
Block a user