Refactor api pagination

This commit is contained in:
Arnau B
2020-11-09 12:56:35 +01:00
parent a4886c99ef
commit d2e9196fba
20 changed files with 257 additions and 359 deletions

View File

@@ -4,7 +4,6 @@ import (
"net/http"
"github.com/gin-gonic/gin"
"github.com/hermeznetwork/hermez-node/db"
"github.com/hermeznetwork/hermez-node/db/historydb"
)
@@ -35,7 +34,7 @@ func (a *API) getHistoryTxs(c *gin.Context) {
}
// Fetch txs from historyDB
txs, pagination, err := a.h.GetHistoryTxs(
txs, pendingItems, err := a.h.GetHistoryTxs(
addr, bjj, tokenID, idx, batchNum, txType, fromItem, limit, order,
)
if err != nil {
@@ -45,12 +44,12 @@ func (a *API) getHistoryTxs(c *gin.Context) {
// Build succesfull response
type txsResponse struct {
Txs []historydb.TxAPI `json:"transactions"`
Pagination *db.Pagination `json:"pagination"`
Txs []historydb.TxAPI `json:"transactions"`
PendingItems uint64 `json:"pendingItems"`
}
c.JSON(http.StatusOK, &txsResponse{
Txs: txs,
Pagination: pagination,
Txs: txs,
PendingItems: pendingItems,
})
}