diff --git a/flags.go b/flags.go index 3439a96..a72ed65 100644 --- a/flags.go +++ b/flags.go @@ -60,6 +60,13 @@ var Pagesize = altsrc.NewUint64Flag(&cli.Uint64Flag{ Destination: &options.PageSize, }) +var Forward = altsrc.NewBoolFlag(&cli.BoolFlag{ + Name: "Pagination Order", + Usage: "Indicates if the entries will be traversed in ascending order (true) or descending order (false)", + Destination: &options.Forward, + Value: false, +}) + var Storenode = cliutils.NewGenericFlagSingleValue(&cli.GenericFlag{ Name: "storenode", Usage: "Multiaddr of a peer that supports store protocol", diff --git a/main.go b/main.go index d884dff..fefa7cf 100644 --- a/main.go +++ b/main.go @@ -37,6 +37,7 @@ type Options struct { Hashes cli.StringSlice AdvanceCursor bool PageSize uint64 + Forward bool StoreNode *multiaddr.Multiaddr UseLegacy bool QueryTimeout time.Duration @@ -154,7 +155,7 @@ func FetchMessage(ctx context.Context, opts Options) error { ctx, cancel := context.WithTimeout(context.Background(), options.QueryTimeout) result, err := wakuNode.Store().Request(ctx, store.MessageHashCriteria{MessageHashes: []pb.MessageHash{pb.ToMessageHash(h)}}, store.WithPeerAddr(*options.StoreNode), - store.WithPaging(false, options.PageSize), + store.WithPaging(options.Forward, options.PageSize), ) cancel() if err != nil { @@ -283,7 +284,7 @@ func QueryMessages(ctx context.Context, opts Options) error { pageCount := 0 if len(result.Messages()) == 0 { - fmt.Println("No messages found (%v)", ellapsed) + fmt.Printf("No messages found (%v)\n", ellapsed) return nil }