Skip to content

Commit

Permalink
Add cli option for limit-per-account in the mempool (#815)
Browse files Browse the repository at this point in the history
* Add cli option for limit-per-account in the mempool

* Update docs, move txpool-limit to solo only
  • Loading branch information
MakisChristou authored Aug 19, 2024
1 parent 47dfc81 commit 8ba7f54
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
10 changes: 5 additions & 5 deletions cmd/thor/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@ var (
Value: "localhost:2112",
Usage: "metrics service listening address",
}
txPoolLimitPerAccountFlag = cli.Uint64Flag{
Name: "txpool-limit-per-account",
Value: 16,
Usage: "set tx limit per account in pool",
}

// solo mode only flags
onDemandFlag = cli.BoolFlag{
Expand All @@ -175,11 +180,6 @@ var (
Value: 10000,
Usage: "set tx limit in pool",
}
txPoolLimitPerAccountFlag = cli.Uint64Flag{
Name: "txpool-limit-per-account",
Value: 16,
Usage: "set tx limit per account in pool",
}
genesisFlag = cli.StringFlag{
Name: "genesis",
Usage: "path to genesis file, if not set, the default devnet genesis will be used",
Expand Down
5 changes: 5 additions & 0 deletions cmd/thor/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ func main() {
disablePrunerFlag,
enableMetricsFlag,
metricsAddrFlag,
txPoolLimitPerAccountFlag,
},
Action: defaultAction,
Commands: []cli.Command{
Expand Down Expand Up @@ -212,6 +213,10 @@ func defaultAction(ctx *cli.Context) error {
}

txpoolOpt := defaultTxPoolOptions
txpoolOpt.LimitPerAccount, err = readIntFromUInt64Flag(ctx.Uint64(txPoolLimitPerAccountFlag.Name))
if err != nil {
return errors.Wrap(err, "parse txpool-limit-per-account flag")
}
txPool := txpool.New(repo, state.NewStater(mainDB), txpoolOpt)
defer func() { log.Info("closing tx pool..."); txPool.Close() }()

Expand Down
3 changes: 2 additions & 1 deletion docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ bin/thor -h
| `--disable-pruner` | Disable state pruner to keep all history |
| `--enable-metrics` | Enables the metrics server |
| `--metrics-addr` | Metrics service listening address |
| `--txpool-limit-per-account`| Transaction pool size limit per account |
| `--help, -h` | Show help |
| `--version, -v` | Print the version |

Expand All @@ -195,7 +196,7 @@ bin/thor -h
| `--persist` | Save blockchain data to disk(default to memory) |
| `--gas-limit` | Gas limit for each block |
| `--txpool-limit` | Transaction pool size limit |
| `--txpool-limit-per-account` | Transaction pool size limit per account |


#### Discovery Node Flags

Expand Down

0 comments on commit 8ba7f54

Please sign in to comment.