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

[R4R]add OnlyPersistent to config of mempool #104

Merged
merged 1 commit into from
Jul 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
4 changes: 2 additions & 2 deletions mempool/reactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const (
maxTxSize = maxMsgSize - 8 // account for amino overhead of TxMessage

MempoolPacketChannelSize = 1024 * 200 // 200K messages can be queued
peerCatchupSleepIntervalMS = 100 // If peer is behind, sleep this amount
peerCatchupSleepIntervalMS = 100 // If peer is behind, sleep this amount

// UnknownPeerID is the peer ID to use when running CheckTx when there is
// no peer (e.g. RPC)
Expand Down Expand Up @@ -211,7 +211,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