mirror of
https://github.com/logos-messaging/logos-messaging-go.git
synced 2026-01-07 16:33:08 +00:00
fix(store): set pagesize behavior match nwaku (#944)
This commit is contained in:
parent
021265eba4
commit
f0ed5e32d5
@ -132,7 +132,7 @@ func getStoreParams(r *http.Request) (*store.Query, []store.HistoryRequestOption
|
|||||||
ascendingStr := r.URL.Query().Get("ascending")
|
ascendingStr := r.URL.Query().Get("ascending")
|
||||||
if ascendingStr != "" || pageSizeStr != "" {
|
if ascendingStr != "" || pageSizeStr != "" {
|
||||||
ascending := true
|
ascending := true
|
||||||
pageSize := uint64(store.MaxPageSize)
|
pageSize := uint64(store.DefaultPageSize)
|
||||||
if ascendingStr != "" {
|
if ascendingStr != "" {
|
||||||
ascending, err = strconv.ParseBool(ascendingStr)
|
ascending, err = strconv.ParseBool(ascendingStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -145,6 +145,9 @@ func getStoreParams(r *http.Request) (*store.Query, []store.HistoryRequestOption
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
if pageSize > store.MaxPageSize {
|
||||||
|
pageSize = store.MaxPageSize
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
options = append(options, store.WithPaging(ascending, pageSize))
|
options = append(options, store.WithPaging(ascending, pageSize))
|
||||||
|
|||||||
@ -195,7 +195,7 @@ func DefaultOptions() []HistoryRequestOption {
|
|||||||
return []HistoryRequestOption{
|
return []HistoryRequestOption{
|
||||||
WithAutomaticRequestID(),
|
WithAutomaticRequestID(),
|
||||||
WithAutomaticPeerSelection(),
|
WithAutomaticPeerSelection(),
|
||||||
WithPaging(true, MaxPageSize),
|
WithPaging(true, DefaultPageSize),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -359,7 +359,9 @@ func (store *WakuStore) Query(ctx context.Context, query Query, opts ...HistoryR
|
|||||||
}
|
}
|
||||||
|
|
||||||
pageSize := params.pageSize
|
pageSize := params.pageSize
|
||||||
if pageSize == 0 || pageSize > uint64(MaxPageSize) {
|
if pageSize == 0 {
|
||||||
|
pageSize = DefaultPageSize
|
||||||
|
} else if pageSize > uint64(MaxPageSize) {
|
||||||
pageSize = MaxPageSize
|
pageSize = MaxPageSize
|
||||||
}
|
}
|
||||||
historyRequest.Query.PagingInfo.PageSize = pageSize
|
historyRequest.Query.PagingInfo.PageSize = pageSize
|
||||||
|
|||||||
@ -19,7 +19,9 @@ const StoreID_v20beta4 = libp2pProtocol.ID("/vac/waku/store/2.0.0-beta4")
|
|||||||
const StoreENRField = uint8(1 << 1)
|
const StoreENRField = uint8(1 << 1)
|
||||||
|
|
||||||
// MaxPageSize is the maximum number of waku messages to return per page
|
// MaxPageSize is the maximum number of waku messages to return per page
|
||||||
const MaxPageSize = 20
|
const MaxPageSize = 100
|
||||||
|
|
||||||
|
const DefaultPageSize = 20
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
||||||
|
|||||||
@ -30,7 +30,9 @@ func findMessages(query *pb.HistoryQuery, msgProvider MessageProvider) ([]*wpb.W
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if query.PagingInfo.PageSize == 0 || query.PagingInfo.PageSize > uint64(MaxPageSize) {
|
if query.PagingInfo.PageSize == 0 {
|
||||||
|
query.PagingInfo.PageSize = DefaultPageSize
|
||||||
|
} else if query.PagingInfo.PageSize > uint64(MaxPageSize) {
|
||||||
query.PagingInfo.PageSize = MaxPageSize
|
query.PagingInfo.PageSize = MaxPageSize
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user