diff --git a/erigon-lib/kv/remotedb/kv_remote.go b/erigon-lib/kv/remotedb/kv_remote.go index c06022bb728..b6e7330ba1a 100644 --- a/erigon-lib/kv/remotedb/kv_remote.go +++ b/erigon-lib/kv/remotedb/kv_remote.go @@ -643,7 +643,7 @@ func (tx *tx) DomainGet(name kv.Domain, k, k2 []byte) (v []byte, step uint64, er func (tx *tx) DomainRange(name kv.Domain, fromKey, toKey []byte, ts uint64, asc order.By, limit int) (it stream.KV, err error) { return stream.PaginateKV(func(pageToken string) (keys, vals [][]byte, nextPageToken string, err error) { - reply, err := tx.db.remoteKV.DomainRange(tx.ctx, &remote.DomainRangeReq{TxId: tx.id, Table: name.String(), FromKey: fromKey, ToKey: toKey, Ts: ts, OrderAscend: bool(asc), Limit: int64(limit)}) + reply, err := tx.db.remoteKV.DomainRange(tx.ctx, &remote.DomainRangeReq{TxId: tx.id, Table: name.String(), FromKey: fromKey, ToKey: toKey, Ts: ts, OrderAscend: bool(asc), Limit: int64(limit), PageToken: pageToken}) if err != nil { return nil, nil, "", err } @@ -659,7 +659,7 @@ func (tx *tx) HistorySeek(name kv.History, k []byte, ts uint64) (v []byte, ok bo } func (tx *tx) HistoryRange(name kv.History, fromTs, toTs int, asc order.By, limit int) (it stream.KV, err error) { return stream.PaginateKV(func(pageToken string) (keys, vals [][]byte, nextPageToken string, err error) { - reply, err := tx.db.remoteKV.HistoryRange(tx.ctx, &remote.HistoryRangeReq{TxId: tx.id, Table: string(name), FromTs: int64(fromTs), ToTs: int64(toTs), OrderAscend: bool(asc), Limit: int64(limit)}) + reply, err := tx.db.remoteKV.HistoryRange(tx.ctx, &remote.HistoryRangeReq{TxId: tx.id, Table: string(name), FromTs: int64(fromTs), ToTs: int64(toTs), OrderAscend: bool(asc), Limit: int64(limit), PageToken: pageToken}) if err != nil { return nil, nil, "", err } @@ -669,7 +669,7 @@ func (tx *tx) HistoryRange(name kv.History, fromTs, toTs int, asc order.By, limi func (tx *tx) IndexRange(name kv.InvertedIdx, k []byte, fromTs, toTs int, asc order.By, limit int) (timestamps stream.U64, err error) { return stream.PaginateU64(func(pageToken string) (arr []uint64, nextPageToken string, err error) { - req := &remote.IndexRangeReq{TxId: tx.id, Table: string(name), K: k, FromTs: int64(fromTs), ToTs: int64(toTs), OrderAscend: bool(asc), Limit: int64(limit)} + req := &remote.IndexRangeReq{TxId: tx.id, Table: string(name), K: k, FromTs: int64(fromTs), ToTs: int64(toTs), OrderAscend: bool(asc), Limit: int64(limit), PageToken: pageToken} reply, err := tx.db.remoteKV.IndexRange(tx.ctx, req) if err != nil { return nil, "", err diff --git a/erigon-lib/kv/remotedbserver/remotedbserver.go b/erigon-lib/kv/remotedbserver/remotedbserver.go index 1450ccbb1b5..a4d4b493945 100644 --- a/erigon-lib/kv/remotedbserver/remotedbserver.go +++ b/erigon-lib/kv/remotedbserver/remotedbserver.go @@ -605,15 +605,13 @@ func (s *KvServer) IndexRange(_ context.Context, req *remote.IndexRangeReq) (*re } reply.Timestamps = append(reply.Timestamps, v) limit-- - } - if len(reply.Timestamps) == int(req.PageSize) && it.HasNext() { - next, err := it.Next() - if err != nil { - return err - } - reply.NextPageToken, err = marshalPagination(&remote.IndexPagination{NextTimeStamp: int64(next), Limit: int64(limit)}) - if err != nil { - return err + + if len(reply.Timestamps) == int(req.PageSize) && it.HasNext() { + reply.NextPageToken, err = marshalPagination(&remote.IndexPagination{NextTimeStamp: int64(v), Limit: int64(limit)}) + if err != nil { + return err + } + break } } return nil @@ -691,15 +689,13 @@ func (s *KvServer) DomainRange(_ context.Context, req *remote.DomainRangeReq) (* reply.Keys = append(reply.Keys, key) reply.Values = append(reply.Values, value) limit-- - } - if len(reply.Keys) == int(req.PageSize) && it.HasNext() { - nextK, _, err := it.Next() - if err != nil { - return err - } - reply.NextPageToken, err = marshalPagination(&remote.PairsPagination{NextKey: nextK, Limit: int64(limit)}) - if err != nil { - return err + + if len(reply.Keys) == int(req.PageSize) && it.HasNext() { + reply.NextPageToken, err = marshalPagination(&remote.PairsPagination{NextKey: k, Limit: int64(limit)}) + if err != nil { + return err + } + break } } return nil