Skip to content

Commit

Permalink
add cmd for message select (#4432)
Browse files Browse the repository at this point in the history
* add cmd for message select

* fix lint
  • Loading branch information
hunjixin authored May 8, 2021
1 parent d323003 commit c3b19f1
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/submodule/chain/actor_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func (actorAPI *ActorAPI) StateGetActor(ctx context.Context, actor address.Addre
return nil, xerrors.Errorf("loading tipset %s: %v", tsk, err)
}

view, err := actorAPI.chain.ChainReader.StateView(ts)
view, err := actorAPI.chain.ChainReader.ParentStateView(ts)
if err != nil {
return nil, xerrors.Errorf("loading tipset %s: %v", tsk, err)
}
Expand Down
30 changes: 30 additions & 0 deletions cmd/mpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ var mpoolCmd = &cmds.Command{
"gas-perf": mpoolGasPerfCmd,
"publish": mpoolPublish,
"delete": mpoolDeleteAddress,
"select": mpoolSelect,
},
}

Expand Down Expand Up @@ -69,6 +70,35 @@ var mpoolDeleteAddress = &cmds.Command{
},
}

var mpoolSelect = &cmds.Command{
Helptext: cmds.HelpText{
Tagline: "select",
ShortDescription: "select message from mpool",
},
Options: []cmds.Option{
cmds.FloatOption("quality", "optionally specify the wallet for publish message").WithDefault(0.5),
},
Run: func(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment) error {
ctx := context.TODO()

quality, _ := req.Options["quality"].(float64)
head, err := env.(*node.Env).ChainAPI.ChainHead(ctx)
if err != nil {
return err
}
msgs, err := env.(*node.Env).MessagePoolAPI.MpoolSelect(ctx, head.Key(), quality)
if err != nil {
return err
}
selectMsg, err := json.MarshalIndent(msgs, " ", "\t")
if err != nil {
return err
}

return printOneString(re, string(selectMsg))
},
}

var mpoolPublish = &cmds.Command{
Helptext: cmds.HelpText{
Tagline: "publish",
Expand Down

0 comments on commit c3b19f1

Please sign in to comment.