mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-12 12:51:22 +00:00
bound mempool memory usage (#3248)
* bound mempool memory usage Closes #3079 * rename SizeBytes to TxsTotalBytes and other small fixes after Zarko's review * rename MaxBytes to MaxTxsTotalBytes * make ErrMempoolIsFull more informative * expose mempool's txs_total_bytes via RPC * test full response * fixes after Ethan's review * config: rename mempool.size to mempool.max_txs https://github.com/tendermint/tendermint/pull/3248#discussion_r254034004 * test more cases https://github.com/tendermint/tendermint/pull/3248#discussion_r254036532 * simplify test * Revert "config: rename mempool.size to mempool.max_txs" This reverts commit 39bfa3696177aa46195000b90655419a975d6ff7. * rename count back to n_txs to make a change non-breaking * rename max_txs_total_bytes to max_txs_bytes * format code * fix TestWALPeriodicSync The test was sometimes failing due to processFlushTicks being called too early. The solution is to call wal#Start later in the test. * Apply suggestions from code review
This commit is contained in:
committed by
Ethan Buchman
parent
e0adc5e807
commit
41f91318e9
@ -248,27 +248,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",
|
||||
// "n_txs" : "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{N: len(txs), Txs: txs}, nil
|
||||
return &ctypes.ResultUnconfirmedTxs{
|
||||
Count: len(txs),
|
||||
Total: mempool.Size(),
|
||||
TotalBytes: mempool.TxsBytes(),
|
||||
Txs: txs}, nil
|
||||
}
|
||||
|
||||
// Get number of unconfirmed transactions.
|
||||
@ -291,15 +296,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" : {
|
||||
// "n_txs" : "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.TxsBytes()}, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user