diff --git a/cmd/geth/main.go b/cmd/geth/main.go index 682746b80cc1..4498393d312b 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -19,6 +19,7 @@ package main import ( "fmt" + "math/big" "os" "sort" "strconv" @@ -428,6 +429,18 @@ func startNode(ctx *cli.Context, stack *node.Node, backend ethapi.Backend, isCon }() } + // CHANGE(MXC) + gasprice := flags.GlobalBig(ctx, utils.MinerGasPriceFlag.Name) + if gasprice.Cmp(big.NewInt(0)) > 0 { + ethBackend, ok := backend.(*eth.EthAPIBackend) + if !ok { + utils.Fatalf("Ethereum service not running") + } + // Set the gas price to the limits from the CLI and start mining + gasprice := flags.GlobalBig(ctx, utils.MinerGasPriceFlag.Name) + ethBackend.TxPool().SetGasPrice(gasprice) + } + // Start auxiliary services if enabled if ctx.Bool(utils.MiningEnabledFlag.Name) || ctx.Bool(utils.DeveloperFlag.Name) { // Mining only makes sense if a full Ethereum node is running diff --git a/core/txpool/txpool.go b/core/txpool/txpool.go index b8322dbf800b..3550e07da5e1 100644 --- a/core/txpool/txpool.go +++ b/core/txpool/txpool.go @@ -695,6 +695,13 @@ func (pool *TxPool) add(tx *types.Transaction, local bool) (replaced bool, err e // the sender is marked as local previously, treat it as the local transaction. isLocal := local || pool.locals.containsTx(tx) + // CHANGE(MXC): check if the transaction gas price is less than the minimum gas price + if tx.GasPrice().Cmp(pool.gasPrice) < 0 { + log.Trace("Discarding underpriced transaction", "hash", hash, "gasPrice", tx.GasPrice(), "local", isLocal) + underpricedTxMeter.Mark(1) + return false, ErrUnderpriced + } + // If the transaction fails basic validation, discard it if err := pool.validateTx(tx, isLocal); err != nil { log.Trace("Discarding invalid transaction", "hash", hash, "err", err)