mirror of
https://github.com/logos-messaging/message-finder.git
synced 2026-01-02 14:03:11 +00:00
feat: pagination order
This commit is contained in:
parent
329af027ab
commit
91ec0ce749
7
flags.go
7
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",
|
||||
|
||||
5
main.go
5
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
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user