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", 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)