mirror of
https://github.com/tendermint/tendermint.git
synced 2026-07-29 11:32:56 +00:00
expose mempool's txs_total_bytes via RPC
This commit is contained in:
@@ -7,6 +7,7 @@ Special thanks to external contributors on this release:
|
||||
### BREAKING CHANGES:
|
||||
|
||||
* CLI/RPC/Config
|
||||
- [rpc] \#3113 rename n_txs to count in `/num_unconfirmed_txs` and `/unconfirmed_txs`
|
||||
|
||||
* Apps
|
||||
|
||||
@@ -19,6 +20,8 @@ Special thanks to external contributors on this release:
|
||||
|
||||
### FEATURES:
|
||||
- [mempool] \#3079 bound mempool memory usage (`mempool.max_txs_total_bytes` is set to 1GB by default; see config.toml)
|
||||
mempool's current `txs_total_bytes` is exposed via `total_bytes` field in
|
||||
`/num_unconfirmed_txs` and `/unconfirmed_txs` RPC endpoints.
|
||||
|
||||
### IMPROVEMENTS:
|
||||
- [tools] add go-deadlock tool to help detect deadlocks
|
||||
|
||||
@@ -311,7 +311,9 @@ func TestNumUnconfirmedTxs(t *testing.T) {
|
||||
res, err := mc.NumUnconfirmedTxs()
|
||||
require.Nil(t, err, "%d: %+v", i, err)
|
||||
|
||||
assert.Equal(t, mempoolSize, res.N)
|
||||
assert.Equal(t, mempoolSize, res.Count)
|
||||
assert.Equal(t, mempoolSize, res.Total)
|
||||
assert.Equal(t, mempool.TxsTotalBytes(), res.TotalBytes)
|
||||
}
|
||||
|
||||
mempool.Flush()
|
||||
|
||||
+27
-18
@@ -255,27 +255,32 @@ func BroadcastTxCommit(tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error) {
|
||||
//
|
||||
// ```json
|
||||
// {
|
||||
// "error": "",
|
||||
// "result": {
|
||||
// "txs": [],
|
||||
// "n_txs": "0"
|
||||
// },
|
||||
// "id": "",
|
||||
// "jsonrpc": "2.0"
|
||||
// }
|
||||
// "result" : {
|
||||
// "txs" : [],
|
||||
// "total_bytes" : "0",
|
||||
// "count" : "0",
|
||||
// "total" : "0"
|
||||
// },
|
||||
// "jsonrpc" : "2.0",
|
||||
// "id" : ""
|
||||
// }
|
||||
// ```
|
||||
//
|
||||
// ### Query Parameters
|
||||
//
|
||||
// | Parameter | Type | Default | Required | Description |
|
||||
// |-----------+------+---------+----------+--------------------------------------|
|
||||
// | limit | int | 30 | false | Maximum number of entries (max: 100) |
|
||||
// ```
|
||||
func UnconfirmedTxs(limit int) (*ctypes.ResultUnconfirmedTxs, error) {
|
||||
// reuse per_page validator
|
||||
limit = validatePerPage(limit)
|
||||
|
||||
txs := mempool.ReapMaxTxs(limit)
|
||||
return &ctypes.ResultUnconfirmedTxs{len(txs), txs}, nil
|
||||
return &ctypes.ResultUnconfirmedTxs{
|
||||
Count: len(txs),
|
||||
Total: mempool.Size(),
|
||||
TotalBytes: mempool.TxsTotalBytes(),
|
||||
Txs: txs}, nil
|
||||
}
|
||||
|
||||
// Get number of unconfirmed transactions.
|
||||
@@ -298,15 +303,19 @@ func UnconfirmedTxs(limit int) (*ctypes.ResultUnconfirmedTxs, error) {
|
||||
//
|
||||
// ```json
|
||||
// {
|
||||
// "error": "",
|
||||
// "result": {
|
||||
// "txs": null,
|
||||
// "n_txs": "0"
|
||||
// },
|
||||
// "id": "",
|
||||
// "jsonrpc": "2.0"
|
||||
// "jsonrpc" : "2.0",
|
||||
// "id" : "",
|
||||
// "result" : {
|
||||
// "count" : "0",
|
||||
// "total_bytes" : "0",
|
||||
// "txs" : null,
|
||||
// "total" : "0"
|
||||
// }
|
||||
// }
|
||||
// ```
|
||||
func NumUnconfirmedTxs() (*ctypes.ResultUnconfirmedTxs, error) {
|
||||
return &ctypes.ResultUnconfirmedTxs{N: mempool.Size()}, nil
|
||||
return &ctypes.ResultUnconfirmedTxs{
|
||||
Count: mempool.Size(),
|
||||
Total: mempool.Size(),
|
||||
TotalBytes: mempool.TxsTotalBytes()}, nil
|
||||
}
|
||||
|
||||
@@ -179,8 +179,10 @@ type ResultTxSearch struct {
|
||||
|
||||
// List of mempool txs
|
||||
type ResultUnconfirmedTxs struct {
|
||||
N int `json:"n_txs"`
|
||||
Txs []types.Tx `json:"txs"`
|
||||
Count int `json:"count"`
|
||||
Total int `json:"total"`
|
||||
TotalBytes int64 `json:"total_bytes"`
|
||||
Txs []types.Tx `json:"txs"`
|
||||
}
|
||||
|
||||
// Info abci msg
|
||||
|
||||
Reference in New Issue
Block a user