How can I make my Ethereum miner choose transactions with low gas?

James: 2 weeks ago

I read a lot that transactions that pay the higher gas price can get their transactions through quicker. I would like to know how I could amend my miner code to select transactions with small fees.

Benjamin: 2 weeks ago

Have a look in commitNewWork() ( in worker.go.

In there ( you have various approaches for how to order transactions within a block.

You'll want to look at the call to SortByPriceAndNonce() (, the definition of which is in transaction.go (

I think you'll basically want to invert the part that sorts by price, giving lower-priced transactions higher priority. (Or however you actually want to prioritise things... )

However, there's some complexity in the algorithm because of how the nonces need to be handled, so you'll have to be careful. (I haven't read the algorithm in full.) From the comment in the code:

// SortByPriceAndNonce sorts the transactions by price in such a way that the
// nonce orderings within a single account are maintained.
// Note, this is not as trivial as it seems from the first look as there are three
// different criteria that need to be taken into account (price, nonce, account
// match), which cannot be done with any plain sorting method, as certain items
// cannot be compared without context.