Skip to content
This repository was archived by the owner on Oct 15, 2024. It is now read-only.

Commit 0b63fbb

Browse files
authored
Merge pull request #104 from binance-chain/mempool
[R4R]add OnlyPersistent to config of mempool
2 parents d64c5a2 + 3caf2c4 commit 0b63fbb

3 files changed

Lines changed: 16 additions & 11 deletions

File tree

config/config.go

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -726,13 +726,14 @@ func (cfg *DBCacheConfig) ToGolevelDBOpt() *optPkg.Options {
726726

727727
// MempoolConfig defines the configuration options for the Tendermint mempool
728728
type MempoolConfig struct {
729-
RootDir string `mapstructure:"home"`
730-
Recheck bool `mapstructure:"recheck"`
731-
Broadcast bool `mapstructure:"broadcast"`
732-
WalPath string `mapstructure:"wal_dir"`
733-
Size int `mapstructure:"size"`
734-
MaxTxsBytes int64 `mapstructure:"max_txs_bytes"`
735-
CacheSize int `mapstructure:"cache_size"`
729+
RootDir string `mapstructure:"home"`
730+
Recheck bool `mapstructure:"recheck"`
731+
Broadcast bool `mapstructure:"broadcast"`
732+
WalPath string `mapstructure:"wal_dir"`
733+
Size int `mapstructure:"size"`
734+
MaxTxsBytes int64 `mapstructure:"max_txs_bytes"`
735+
CacheSize int `mapstructure:"cache_size"`
736+
OnlyPersistent bool `mapstructure:"only_persistent"`
736737
}
737738

738739
// DefaultMempoolConfig returns a default configuration for the Tendermint mempool
@@ -743,9 +744,10 @@ func DefaultMempoolConfig() *MempoolConfig {
743744
WalPath: "",
744745
// Each signature verification takes .5ms, Size reduced until we implement
745746
// ABCI Recheck
746-
Size: 5000,
747-
MaxTxsBytes: 1024 * 1024 * 1024, // 1GB
748-
CacheSize: 10000,
747+
Size: 5000,
748+
MaxTxsBytes: 1024 * 1024 * 1024, // 1GB
749+
CacheSize: 10000,
750+
OnlyPersistent: false,
749751
}
750752
}
751753

config/toml.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,9 @@ recheck = {{ .Mempool.Recheck }}
321321
broadcast = {{ .Mempool.Broadcast }}
322322
wal_dir = "{{ js .Mempool.WalPath }}"
323323
324+
# If set true, will only broadcast transactions to persistent peers.
325+
only_persistent = {{ .Mempool.OnlyPersistent }}
326+
324327
# Maximum number of transactions in the mempool
325328
size = {{ .Mempool.Size }}
326329

mempool/reactor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ type PeerState interface {
215215

216216
// Send new mempool txs to peer.
217217
func (memR *MempoolReactor) broadcastTxRoutine(peer p2p.Peer) {
218-
if !memR.config.Broadcast {
218+
if !memR.config.Broadcast || (memR.config.OnlyPersistent && !memR.Switch.IsPersistent(peer)) {
219219
return
220220
}
221221

0 commit comments

Comments
 (0)