-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feat: add ordering by nonce flag to get sequential messages #13394
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
base: master
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -836,6 +836,10 @@ var StateListMessagesCmd = &cli.Command{ | |
| Name: "cids", | ||
| Usage: "print message CIDs instead of messages", | ||
| }, | ||
| &cli.BoolFlag{ | ||
| Name: "order-by-nonce", | ||
| Usage: "order messages by nonce (only applies when filtering by 'from' address)", | ||
| }, | ||
| }, | ||
| Action: func(cctx *cli.Context) error { | ||
| api, closer, err := GetFullNodeAPI(cctx) | ||
|
|
@@ -872,6 +876,13 @@ var StateListMessagesCmd = &cli.Command{ | |
|
|
||
| windowSize := abi.ChainEpoch(100) | ||
|
|
||
| obn := cctx.Bool("order-by-nonce") && !froma.Empty() | ||
|
|
||
| var orderedMessages []struct { | ||
| Nonce uint64 | ||
| Msg []byte | ||
| } | ||
|
Comment on lines
+881
to
+884
|
||
|
|
||
| cur := ts | ||
| for cur.Height() > toh { | ||
| if ctx.Err() != nil { | ||
|
|
@@ -898,11 +909,21 @@ var StateListMessagesCmd = &cli.Command{ | |
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| b, err := json.MarshalIndent(m, "", " ") | ||
| if err != nil { | ||
| return err | ||
| } | ||
| fmt.Println(string(b)) | ||
|
|
||
| if obn { | ||
| orderedMessages = append(orderedMessages, struct { | ||
| Nonce uint64 | ||
| Msg []byte | ||
| }{Nonce: m.Nonce, Msg: b}) | ||
| continue | ||
| } else { | ||
| fmt.Println(string(b)) | ||
| } | ||
DarkLord017 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| if end <= 0 { | ||
|
|
@@ -917,6 +938,15 @@ var StateListMessagesCmd = &cli.Command{ | |
| cur = next | ||
| } | ||
|
|
||
| if obn { | ||
| sort.Slice(orderedMessages, func(i, j int) bool { | ||
| return orderedMessages[i].Nonce < orderedMessages[j].Nonce | ||
| }) | ||
| for _, om := range orderedMessages { | ||
| fmt.Println(string(om.Msg)) | ||
| } | ||
| } | ||
|
|
||
| return nil | ||
| }, | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.