Merge pull request #5035 from filecoin-project/feat/mpool-stat-gas

Print gas limit sum in mpool stat
This commit is contained in:
Łukasz Magiera 2020-11-27 20:05:03 +01:00 committed by GitHub
commit 660ac26dd9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -233,6 +233,7 @@ var mpoolStat = &cli.Command{
addr string
past, cur, future uint64
belowCurr, belowPast uint64
gasLimit big.Int
}
buckets := map[address.Address]*statBucket{}
@ -274,6 +275,7 @@ var mpoolStat = &cli.Command{
var s mpStat
s.addr = a.String()
s.gasLimit = big.Zero()
for _, m := range bkt.msgs {
if m.Message.Nonce < act.Nonce {
@ -290,6 +292,8 @@ var mpoolStat = &cli.Command{
if m.Message.GasFeeCap.LessThan(minBF) {
s.belowPast++
}
s.gasLimit = big.Add(s.gasLimit, types.NewInt(uint64(m.Message.GasLimit)))
}
out = append(out, s)
@ -300,6 +304,7 @@ var mpoolStat = &cli.Command{
})
var total mpStat
total.gasLimit = big.Zero()
for _, stat := range out {
total.past += stat.past
@ -307,12 +312,13 @@ var mpoolStat = &cli.Command{
total.future += stat.future
total.belowCurr += stat.belowCurr
total.belowPast += stat.belowPast
total.gasLimit = big.Add(total.gasLimit, stat.gasLimit)
fmt.Printf("%s: Nonce past: %d, cur: %d, future: %d; FeeCap cur: %d, min-%d: %d \n", stat.addr, stat.past, stat.cur, stat.future, stat.belowCurr, cctx.Int("basefee-lookback"), stat.belowPast)
fmt.Printf("%s: Nonce past: %d, cur: %d, future: %d; FeeCap cur: %d, min-%d: %d, gasLimit: %s\n", stat.addr, stat.past, stat.cur, stat.future, stat.belowCurr, cctx.Int("basefee-lookback"), stat.belowPast, stat.gasLimit)
}
fmt.Println("-----")
fmt.Printf("total: Nonce past: %d, cur: %d, future: %d; FeeCap cur: %d, min-%d: %d \n", total.past, total.cur, total.future, total.belowCurr, cctx.Int("basefee-lookback"), total.belowPast)
fmt.Printf("total: Nonce past: %d, cur: %d, future: %d; FeeCap cur: %d, min-%d: %d, gasLimit: %s\n", total.past, total.cur, total.future, total.belowCurr, cctx.Int("basefee-lookback"), total.belowPast, total.gasLimit)
return nil
},