diff --git a/rpc/core/mempool.go b/rpc/core/mempool.go index 77c8c8446..0e4772434 100644 --- a/rpc/core/mempool.go +++ b/rpc/core/mempool.go @@ -209,7 +209,7 @@ func BroadcastTxCommit(tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error) { } } -// Get unconfirmed transactions including their number. +// Get unconfirmed transactions (maximum ?limit entries) including their number. // // ```shell // curl 'localhost:46657/unconfirmed_txs' @@ -232,9 +232,18 @@ func BroadcastTxCommit(tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error) { // "id": "", // "jsonrpc": "2.0" // } +// +// ### Query Parameters +// +// | Parameter | Type | Default | Required | Description | +// |-----------+------+---------+----------+--------------------------------------| +// | limit | int | 30 | false | Maximum number of entries (max: 100) | // ``` -func UnconfirmedTxs() (*ctypes.ResultUnconfirmedTxs, error) { - txs := mempool.Reap(-1) +func UnconfirmedTxs(limit int) (*ctypes.ResultUnconfirmedTxs, error) { + // reuse per_page validator + limit = validatePerPage(limit) + + txs := mempool.Reap(limit) return &ctypes.ResultUnconfirmedTxs{len(txs), txs}, nil } diff --git a/rpc/core/routes.go b/rpc/core/routes.go index ed6c69815..f26fadb62 100644 --- a/rpc/core/routes.go +++ b/rpc/core/routes.go @@ -26,7 +26,7 @@ var Routes = map[string]*rpc.RPCFunc{ "validators": rpc.NewRPCFunc(Validators, "height"), "dump_consensus_state": rpc.NewRPCFunc(DumpConsensusState, ""), "consensus_state": rpc.NewRPCFunc(ConsensusState, ""), - "unconfirmed_txs": rpc.NewRPCFunc(UnconfirmedTxs, ""), + "unconfirmed_txs": rpc.NewRPCFunc(UnconfirmedTxs, "limit"), "num_unconfirmed_txs": rpc.NewRPCFunc(NumUnconfirmedTxs, ""), // broadcast API