Skip to content

Commit

Permalink
add option to reannounce local transactions (bnb-chain#33)
Browse files Browse the repository at this point in the history
Co-authored-by: andyzhang2023 <andyzhang2023@gmail.com>
Co-authored-by: Owen <103096885+owen-reorg@users.noreply.github.com>
  • Loading branch information
3 people authored Nov 24, 2023
1 parent c36a3ce commit feb5339
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ var (
utils.TxPoolGlobalQueueFlag,
utils.TxPoolLifetimeFlag,
utils.TxPoolReannounceTimeFlag,
utils.TxPoolReannounceRemotesFlag,
utils.SyncModeFlag,
utils.SyncTargetFlag,
utils.ExitWhenSyncedFlag,
Expand Down
9 changes: 9 additions & 0 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,12 @@ var (
Value: ethconfig.Defaults.TxPool.ReannounceTime,
Category: flags.TxPoolCategory,
}
TxPoolReannounceRemotesFlag = &cli.BoolFlag{
Name: "txpool.reannounceremotes",
Usage: "Wether reannnounce remote transactions or not(default = false)",
Value: ethconfig.Defaults.TxPool.ReannounceRemotes,
Category: flags.TxPoolCategory,
}

// Performance tuning settings
CacheFlag = &cli.IntFlag{
Expand Down Expand Up @@ -1669,6 +1675,9 @@ func setTxPool(ctx *cli.Context, cfg *txpool.Config) {
if ctx.IsSet(TxPoolReannounceTimeFlag.Name) {
cfg.ReannounceTime = ctx.Duration(TxPoolReannounceTimeFlag.Name)
}
if ctx.IsSet(TxPoolReannounceRemotesFlag.Name) {
cfg.ReannounceRemotes = ctx.Bool(TxPoolReannounceRemotesFlag.Name)
}
}

func setEthash(ctx *cli.Context, cfg *ethconfig.Config) {
Expand Down
7 changes: 4 additions & 3 deletions core/txpool/txpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,9 @@ type Config struct {
AccountQueue uint64 // Maximum number of non-executable transaction slots permitted per account
GlobalQueue uint64 // Maximum number of non-executable transaction slots for all accounts

Lifetime time.Duration // Maximum amount of time non-executable transaction are queued
ReannounceTime time.Duration // Duration for announcing local pending transactions again
Lifetime time.Duration // Maximum amount of time non-executable transaction are queued
ReannounceTime time.Duration // Duration for announcing local pending transactions again
ReannounceRemotes bool // Wether reannounce remote transactions or not
}

// DefaultConfig contains the default configurations for the transaction
Expand Down Expand Up @@ -433,7 +434,7 @@ func (pool *TxPool) loop() {
reannoTxs := func() []*types.Transaction {
txs := make([]*types.Transaction, 0)
for addr, list := range pool.pending {
if !pool.locals.contains(addr) {
if !pool.config.ReannounceRemotes && !pool.locals.contains(addr) {
continue
}

Expand Down

0 comments on commit feb5339

Please sign in to comment.