Merge pull request #895 from filecoin-project/fix/message-count

Maybe fix messange count?
This commit is contained in:
Łukasz Magiera 2019-12-13 12:52:31 +01:00 committed by GitHub
commit f4955dd359
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -14,6 +14,7 @@ import (
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/address"
"github.com/filecoin-project/lotus/chain/types"
"github.com/ipfs/go-cid"
"github.com/multiformats/go-multihash"
_ "github.com/influxdata/influxdb1-client"
@ -182,6 +183,12 @@ func RecordTipsetStatePoints(ctx context.Context, api api.FullNode, pl *PointLis
return nil
}
type msgTag struct {
actor string
method uint64
exitcode uint8
}
func RecordTipsetMessagesPoints(ctx context.Context, api api.FullNode, pl *PointList, tipset *types.TipSet) error {
cids := tipset.Cids()
if len(cids) == 0 {
@ -198,6 +205,8 @@ func RecordTipsetMessagesPoints(ctx context.Context, api api.FullNode, pl *Point
return err
}
msgn := make(map[msgTag][]cid.Cid)
for i, msg := range msgs {
p := NewPoint("chain.message_gasprice", msg.Message.GasPrice.Int64())
pl.AddPoint(p)
@ -215,16 +224,33 @@ func RecordTipsetMessagesPoints(ctx context.Context, api api.FullNode, pl *Point
return err
}
p = NewPoint("chain.message_count", 1)
dm, err := multihash.Decode(actor.Code.Hash())
if err != nil {
continue
}
tag := msgTag{
actor: string(dm.Digest),
method: msg.Message.Method,
exitcode: recp[i].ExitCode,
}
p.AddTag("actor", string(dm.Digest))
p.AddTag("method", fmt.Sprintf("%d", msg.Message.Method))
p.AddTag("exitcode", fmt.Sprintf("%d", recp[i].ExitCode))
found := false
for _, c := range msgn[tag] {
if c.Equals(msg.Cid) {
found = true
break
}
}
if !found {
msgn[tag] = append(msgn[tag], msg.Cid)
}
}
for t, m := range msgn {
p := NewPoint("chain.message_count", len(m))
p.AddTag("actor", t.actor)
p.AddTag("method", fmt.Sprintf("%d", t.method))
p.AddTag("exitcode", fmt.Sprintf("%d", t.exitcode))
pl.AddPoint(p)
}