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

Commit

Permalink
Merge pull request #104 from binance-chain/mempool
Browse files Browse the repository at this point in the history
[R4R]add OnlyPersistent to config of mempool
  • Loading branch information
unclezoro authored Jul 19, 2019
2 parents d64c5a2 + 3caf2c4 commit 0b63fbb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
22 changes: 12 additions & 10 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
}
}

Expand Down
3 changes: 3 additions & 0 deletions config/toml.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
2 changes: 1 addition & 1 deletion mempool/reactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 0b63fbb

Please sign in to comment.