diff --git a/config/config.go b/config/config.go index 46ae795b5..b83b0492d 100644 --- a/config/config.go +++ b/config/config.go @@ -726,13 +726,14 @@ func (cfg *DBCacheConfig) ToGolevelDBOpt() *optPkg.Options { // 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"` - MaxTxsBytes int64 `mapstructure:"max_txs_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"` + MaxTxsBytes int64 `mapstructure:"max_txs_bytes"` + CacheSize int `mapstructure:"cache_size"` + OnlyPersistent bool `mapstructure:"only_persistent"` } // DefaultMempoolConfig returns a default configuration for the Tendermint mempool @@ -743,9 +744,10 @@ func DefaultMempoolConfig() *MempoolConfig { WalPath: "", // Each signature verification takes .5ms, Size reduced until we implement // ABCI Recheck - Size: 5000, - MaxTxsBytes: 1024 * 1024 * 1024, // 1GB - CacheSize: 10000, + Size: 5000, + MaxTxsBytes: 1024 * 1024 * 1024, // 1GB + CacheSize: 10000, + OnlyPersistent: false, } } diff --git a/config/toml.go b/config/toml.go index c8e848de0..a2b55c36d 100644 --- a/config/toml.go +++ b/config/toml.go @@ -321,6 +321,9 @@ recheck = {{ .Mempool.Recheck }} broadcast = {{ .Mempool.Broadcast }} wal_dir = "{{ js .Mempool.WalPath }}" +# If set true, will only broadcast transactions to persistent peers. +only_persistent = {{ .Mempool.OnlyPersistent }} + # Maximum number of transactions in the mempool size = {{ .Mempool.Size }} diff --git a/mempool/reactor.go b/mempool/reactor.go index bd170204b..6f716ecf8 100644 --- a/mempool/reactor.go +++ b/mempool/reactor.go @@ -215,7 +215,7 @@ type PeerState interface { // Send new mempool txs to peer. func (memR *MempoolReactor) broadcastTxRoutine(peer p2p.Peer) { - if !memR.config.Broadcast { + if !memR.config.Broadcast || (memR.config.OnlyPersistent && !memR.Switch.IsPersistent(peer)) { return }