Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add cmd for message select #4432

Merged
merged 2 commits into from
May 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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