From fe8726ecf309a1a75bd66cee5e170b793835e195 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Tue, 5 Feb 2019 20:02:26 +0400 Subject: [PATCH] rename MaxBytes to MaxTxsTotalBytes --- CHANGELOG_PENDING.md | 2 +- config/config.go | 24 ++++++++++++------------ config/toml.go | 6 +++--- docs/tendermint-core/configuration.md | 6 +++--- mempool/mempool.go | 2 +- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/CHANGELOG_PENDING.md b/CHANGELOG_PENDING.md index e5cf12279..d9fdacda8 100644 --- a/CHANGELOG_PENDING.md +++ b/CHANGELOG_PENDING.md @@ -18,7 +18,7 @@ Special thanks to external contributors on this release: * P2P Protocol ### FEATURES: -- [mempool] \#3079 bound mempool memory usage (`mempool.max_bytes` is set to 1GB by default; see config.toml) +- [mempool] \#3079 bound mempool memory usage (`mempool.max_txs_total_bytes` is set to 1GB by default; see config.toml) ### IMPROVEMENTS: - [tools] add go-deadlock tool to help detect deadlocks diff --git a/config/config.go b/config/config.go index a16666829..b6577c55f 100644 --- a/config/config.go +++ b/config/config.go @@ -530,13 +530,13 @@ func DefaultFuzzConnConfig() *FuzzConnConfig { // MempoolConfig defines the configuration options for the Tendermint mempool type MempoolConfig struct { - RootDir string `mapstructure:"home"` - Recheck bool `mapstructure:"recheck"` - Broadcast bool `mapstructure:"broadcast"` - WalPath string `mapstructure:"wal_dir"` - Size int `mapstructure:"size"` - MaxBytes int64 `mapstructure:"max_bytes"` - CacheSize int `mapstructure:"cache_size"` + RootDir string `mapstructure:"home"` + Recheck bool `mapstructure:"recheck"` + Broadcast bool `mapstructure:"broadcast"` + WalPath string `mapstructure:"wal_dir"` + Size int `mapstructure:"size"` + MaxTxsTotalBytes int64 `mapstructure:"max_txs_total_bytes"` + CacheSize int `mapstructure:"cache_size"` } // DefaultMempoolConfig returns a default configuration for the Tendermint mempool @@ -547,9 +547,9 @@ func DefaultMempoolConfig() *MempoolConfig { WalPath: "", // Each signature verification takes .5ms, Size reduced until we implement // ABCI Recheck - Size: 5000, - MaxBytes: 1024 * 1024 * 1024, // 1GB - CacheSize: 10000, + Size: 5000, + MaxTxsTotalBytes: 1024 * 1024 * 1024, // 1GB + CacheSize: 10000, } } @@ -576,8 +576,8 @@ func (cfg *MempoolConfig) ValidateBasic() error { if cfg.Size < 0 { return errors.New("size can't be negative") } - if cfg.MaxBytes < 0 { - return errors.New("max_bytes can't be negative") + if cfg.MaxTxsTotalBytes < 0 { + return errors.New("max_txs_total_bytes can't be negative") } if cfg.CacheSize < 0 { return errors.New("cache_size can't be negative") diff --git a/config/toml.go b/config/toml.go index 9799c636b..e179f4e02 100644 --- a/config/toml.go +++ b/config/toml.go @@ -237,10 +237,10 @@ wal_dir = "{{ js .Mempool.WalPath }}" # Maximum number of transactions in the mempool size = {{ .Mempool.Size }} -# Maximum size of the mempool in bytes +# Limit the total size of all txs in the mempool. # This only accounts for raw transactions (e.g. given 1MB transactions and -# max_bytes=5MB, mempool will only accept 5 transactions). -max_bytes = {{ .Mempool.MaxBytes }} +# max_txs_total_bytes=5MB, mempool will only accept 5 transactions). +max_txs_total_bytes = {{ .Mempool.MaxTxsTotalBytes }} # Size of the cache (used to filter transactions we saw earlier) in transactions cache_size = {{ .Mempool.CacheSize }} diff --git a/docs/tendermint-core/configuration.md b/docs/tendermint-core/configuration.md index 192adaa07..6ed9ebec2 100644 --- a/docs/tendermint-core/configuration.md +++ b/docs/tendermint-core/configuration.md @@ -186,10 +186,10 @@ wal_dir = "" # Maximum number of transactions in the mempool size = 5000 -# Maximum size of the mempool in bytes +# Limit the total size of all txs in the mempool. # This only accounts for raw transactions (e.g. given 1MB transactions and -# max_bytes=5MB, mempool will only accept 5 transactions). -max_bytes = 1073741824 +# max_txs_total_bytes=5MB, mempool will only accept 5 transactions). +max_txs_total_bytes = 1073741824 # Size of the cache (used to filter transactions we saw earlier) in transactions cache_size = 10000 diff --git a/mempool/mempool.go b/mempool/mempool.go index cb0d9edc1..a44e8c617 100644 --- a/mempool/mempool.go +++ b/mempool/mempool.go @@ -319,7 +319,7 @@ func (mem *Mempool) CheckTx(tx types.Tx, cb func(*abci.Response)) (err error) { if mem.Size() >= mem.config.Size { return ErrMempoolIsFull - } else if int64(len(tx))+mem.TxsTotalBytes() > mem.config.MaxBytes { + } else if int64(len(tx))+mem.TxsTotalBytes() > mem.config.MaxTxsTotalBytes { return ErrMempoolIsFull }