mirror of https://github.com/status-im/go-waku.git
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")
|
||||
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))
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 (
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue