Browse Source

add limit param to /unconfirmed_txs

pull/1567/head
Anton Kaliaev 7 years ago
parent
commit
5115618550
No known key found for this signature in database GPG Key ID: 7B6881D965918214
2 changed files with 13 additions and 4 deletions
  1. +12
    -3
      rpc/core/mempool.go
  2. +1
    -1
      rpc/core/routes.go

+ 12
- 3
rpc/core/mempool.go View File

@ -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 // ```shell
// curl 'localhost:46657/unconfirmed_txs' // curl 'localhost:46657/unconfirmed_txs'
@ -232,9 +232,18 @@ func BroadcastTxCommit(tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error) {
// "id": "", // "id": "",
// "jsonrpc": "2.0" // "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 return &ctypes.ResultUnconfirmedTxs{len(txs), txs}, nil
} }


+ 1
- 1
rpc/core/routes.go View File

@ -26,7 +26,7 @@ var Routes = map[string]*rpc.RPCFunc{
"validators": rpc.NewRPCFunc(Validators, "height"), "validators": rpc.NewRPCFunc(Validators, "height"),
"dump_consensus_state": rpc.NewRPCFunc(DumpConsensusState, ""), "dump_consensus_state": rpc.NewRPCFunc(DumpConsensusState, ""),
"consensus_state": rpc.NewRPCFunc(ConsensusState, ""), "consensus_state": rpc.NewRPCFunc(ConsensusState, ""),
"unconfirmed_txs": rpc.NewRPCFunc(UnconfirmedTxs, ""),
"unconfirmed_txs": rpc.NewRPCFunc(UnconfirmedTxs, "limit"),
"num_unconfirmed_txs": rpc.NewRPCFunc(NumUnconfirmedTxs, ""), "num_unconfirmed_txs": rpc.NewRPCFunc(NumUnconfirmedTxs, ""),
// broadcast API // broadcast API


Loading…
Cancel
Save