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 mpoolpending from to filter #5169

Merged
merged 1 commit into from
Dec 10, 2020
Merged
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
32 changes: 32 additions & 0 deletions cli/mpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ var mpoolPending = &cli.Command{
Name: "cids",
Usage: "only print cids of messages in output",
},
&cli.StringFlag{
Name: "to",
Usage: "return messages to a given address",
},
&cli.StringFlag{
Name: "from",
Usage: "return messages from a given address",
},
},
Action: func(cctx *cli.Context) error {
api, closer, err := GetFullNodeAPI(cctx)
Expand All @@ -59,6 +67,23 @@ var mpoolPending = &cli.Command{

ctx := ReqContext(cctx)

var toa, froma address.Address
if tos := cctx.String("to"); tos != "" {
a, err := address.NewFromString(tos)
if err != nil {
return fmt.Errorf("given 'to' address %q was invalid: %w", tos, err)
}
toa = a
}

if froms := cctx.String("from"); froms != "" {
a, err := address.NewFromString(froms)
if err != nil {
return fmt.Errorf("given 'from' address %q was invalid: %w", froms, err)
}
froma = a
}

var filter map[address.Address]struct{}
if cctx.Bool("local") {
filter = map[address.Address]struct{}{}
Expand All @@ -85,6 +110,13 @@ var mpoolPending = &cli.Command{
}
}

if toa != address.Undef && msg.Message.To != toa {
continue
}
if froma != address.Undef && msg.Message.From != froma {
continue
}

if cctx.Bool("cids") {
fmt.Println(msg.Cid())
} else {
Expand Down