mirror of
https://github.com/logos-messaging/message-finder.git
synced 2026-01-07 16:33:07 +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,
|
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{
|
var Storenode = cliutils.NewGenericFlagSingleValue(&cli.GenericFlag{
|
||||||
Name: "storenode",
|
Name: "storenode",
|
||||||
Usage: "Multiaddr of a peer that supports store protocol",
|
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
|
Hashes cli.StringSlice
|
||||||
AdvanceCursor bool
|
AdvanceCursor bool
|
||||||
PageSize uint64
|
PageSize uint64
|
||||||
|
Forward bool
|
||||||
StoreNode *multiaddr.Multiaddr
|
StoreNode *multiaddr.Multiaddr
|
||||||
UseLegacy bool
|
UseLegacy bool
|
||||||
QueryTimeout time.Duration
|
QueryTimeout time.Duration
|
||||||
@ -154,7 +155,7 @@ func FetchMessage(ctx context.Context, opts Options) error {
|
|||||||
ctx, cancel := context.WithTimeout(context.Background(), options.QueryTimeout)
|
ctx, cancel := context.WithTimeout(context.Background(), options.QueryTimeout)
|
||||||
result, err := wakuNode.Store().Request(ctx, store.MessageHashCriteria{MessageHashes: []pb.MessageHash{pb.ToMessageHash(h)}},
|
result, err := wakuNode.Store().Request(ctx, store.MessageHashCriteria{MessageHashes: []pb.MessageHash{pb.ToMessageHash(h)}},
|
||||||
store.WithPeerAddr(*options.StoreNode),
|
store.WithPeerAddr(*options.StoreNode),
|
||||||
store.WithPaging(false, options.PageSize),
|
store.WithPaging(options.Forward, options.PageSize),
|
||||||
)
|
)
|
||||||
cancel()
|
cancel()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -283,7 +284,7 @@ func QueryMessages(ctx context.Context, opts Options) error {
|
|||||||
pageCount := 0
|
pageCount := 0
|
||||||
|
|
||||||
if len(result.Messages()) == 0 {
|
if len(result.Messages()) == 0 {
|
||||||
fmt.Println("No messages found (%v)", ellapsed)
|
fmt.Printf("No messages found (%v)\n", ellapsed)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user