Skip to content

Commit

Permalink
Merge pull request #5169 from filcloud/5141-mpoolpending
Browse files Browse the repository at this point in the history
add mpoolpending from to filter
  • Loading branch information
magik6k authored Dec 10, 2020
2 parents 4767773 + 0f08da3 commit 58729b7
Showing 1 changed file with 32 additions and 0 deletions.
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

0 comments on commit 58729b7

Please sign in to comment.