Skip to content

Commit

Permalink
Merge pull request #5035 from filecoin-project/feat/mpool-stat-gas
Browse files Browse the repository at this point in the history
Print gas limit sum in mpool stat
  • Loading branch information
magik6k authored Nov 27, 2020
2 parents 13a5b7f + 09b9dfc commit 660ac26
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions cli/mpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand Down Expand Up @@ -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 {
Expand All @@ -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)
Expand All @@ -300,19 +304,21 @@ var mpoolStat = &cli.Command{
})

var total mpStat
total.gasLimit = big.Zero()

for _, stat := range out {
total.past += stat.past
total.cur += stat.cur
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
},
Expand Down

0 comments on commit 660ac26

Please sign in to comment.