fix(store): set pagesize behavior match nwaku (#944)

This commit is contained in:
richΛrd 2023-12-06 09:02:05 -04:00 committed by GitHub
parent 021265eba4
commit f0ed5e32d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 5 deletions

View File

@ -132,7 +132,7 @@ func getStoreParams(r *http.Request) (*store.Query, []store.HistoryRequestOption
ascendingStr := r.URL.Query().Get("ascending")
if ascendingStr != "" || pageSizeStr != "" {
ascending := true
pageSize := uint64(store.MaxPageSize)
pageSize := uint64(store.DefaultPageSize)
if ascendingStr != "" {
ascending, err = strconv.ParseBool(ascendingStr)
if err != nil {
@ -145,6 +145,9 @@ func getStoreParams(r *http.Request) (*store.Query, []store.HistoryRequestOption
if err != nil {
return nil, nil, err
}
if pageSize > store.MaxPageSize {
pageSize = store.MaxPageSize
}
}
options = append(options, store.WithPaging(ascending, pageSize))

View File

@ -195,7 +195,7 @@ func DefaultOptions() []HistoryRequestOption {
return []HistoryRequestOption{
WithAutomaticRequestID(),
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
if pageSize == 0 || pageSize > uint64(MaxPageSize) {
if pageSize == 0 {
pageSize = DefaultPageSize
} else if pageSize > uint64(MaxPageSize) {
pageSize = MaxPageSize
}
historyRequest.Query.PagingInfo.PageSize = pageSize

View File

@ -19,7 +19,9 @@ const StoreID_v20beta4 = libp2pProtocol.ID("/vac/waku/store/2.0.0-beta4")
const StoreENRField = uint8(1 << 1)
// MaxPageSize is the maximum number of waku messages to return per page
const MaxPageSize = 20
const MaxPageSize = 100
const DefaultPageSize = 20
var (

View File

@ -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
}