Merge pull request #5968 from filcloud/ping-ask

remove duplicate ask and calculate ping before lock
This commit is contained in:
Łukasz Magiera 2021-04-29 21:12:37 +02:00 committed by GitHub
commit 462a44902e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1296,7 +1296,8 @@ var clientListAsksCmd = &cli.Command{
Usage: "List asks for top miners",
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "by-ping",
Name: "by-ping",
Usage: "sort by ping",
},
&cli.StringFlag{
Name: "output-format",
@ -1451,17 +1452,17 @@ loop:
}
rt := time.Now()
_, err = api.ClientQueryAsk(ctx, *mi.PeerId, miner)
if err != nil {
return
}
pingDuration := time.Now().Sub(rt)
atomic.AddInt64(&got, 1)
lk.Lock()
asks = append(asks, QueriedAsk{
Ask: ask,
Ping: time.Now().Sub(rt),
Ping: pingDuration,
})
lk.Unlock()
}(miner)