mirror of
https://github.com/arnaucube/hermez-node.git
synced 2026-02-07 03:16:45 +01:00
implemented fromIdx and toIdx in transaction-pool request
This commit is contained in:
@@ -172,6 +172,18 @@ func parseIdx(c querier) (*common.Idx, error) {
|
||||
return stringToIdx(idxStr, name)
|
||||
}
|
||||
|
||||
func parseFromIdx(c querier) (*common.Idx, error) {
|
||||
const name = "fromAccountIndex"
|
||||
idxStr := c.Query(name)
|
||||
return stringToIdx(idxStr, name)
|
||||
}
|
||||
|
||||
func parseToIdx(c querier) (*common.Idx, error) {
|
||||
const name = "toAccountIndex"
|
||||
idxStr := c.Query(name)
|
||||
return stringToIdx(idxStr, name)
|
||||
}
|
||||
|
||||
func parseExitFilters(c querier) (*common.TokenID, *ethCommon.Address, *babyjub.PublicKeyComp, *common.Idx, error) {
|
||||
// TokenID
|
||||
tid, err := parseQueryUint("tokenId", nil, 0, maxUint32, c)
|
||||
|
||||
@@ -427,10 +427,16 @@ paths:
|
||||
description: State of the transactions, e.g. "pend"
|
||||
schema:
|
||||
$ref: '#/components/schemas/PoolL2TransactionState'
|
||||
- name: accountIndex
|
||||
- name: fromAccountIndex
|
||||
in: query
|
||||
required: false
|
||||
description: Id of the account
|
||||
description: Id of the from account
|
||||
schema:
|
||||
$ref: '#/components/schemas/AccountIndex'
|
||||
- name: toAccountIndex
|
||||
in: query
|
||||
required: false
|
||||
description: Id of the to account
|
||||
schema:
|
||||
$ref: '#/components/schemas/AccountIndex'
|
||||
responses:
|
||||
|
||||
@@ -56,8 +56,14 @@ func (a *API) getPoolTx(c *gin.Context) {
|
||||
}
|
||||
|
||||
func (a *API) getPoolTxs(c *gin.Context) {
|
||||
// Get idx
|
||||
idx, err := parseIdx(c)
|
||||
// Get from idx
|
||||
fromIdx, err := parseFromIdx(c)
|
||||
if err != nil {
|
||||
retBadReq(err, c)
|
||||
return
|
||||
}
|
||||
// Get to idx
|
||||
toIdx, err := parseToIdx(c)
|
||||
if err != nil {
|
||||
retBadReq(err, c)
|
||||
return
|
||||
@@ -69,7 +75,7 @@ func (a *API) getPoolTxs(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
// Fetch txs from l2DB
|
||||
txs, err := a.l2.GetPoolTxs(idx, state)
|
||||
txs, err := a.l2.GetPoolTxs(fromIdx, toIdx, state)
|
||||
if err != nil {
|
||||
retSQLErr(err, c)
|
||||
return
|
||||
|
||||
@@ -233,7 +233,7 @@ func TestPoolTxs(t *testing.T) {
|
||||
fetchedTxs := testPoolTxsResponse{}
|
||||
require.NoError(t, doGoodReq(
|
||||
"GET",
|
||||
endpoint+"?accountIndex=hez:ETH:263",
|
||||
endpoint+"?fromAccountIndex=hez:ETH:263",
|
||||
nil, &fetchedTxs))
|
||||
assert.Equal(t, 1, len(fetchedTxs.Txs))
|
||||
assert.Equal(t, "hez:ETH:263", fetchedTxs.Txs[0].FromIdx)
|
||||
|
||||
Reference in New Issue
Block a user