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.
1Which client are you running? Geth, or something else?– Richard HorrocksDec 19, 2017 at 12:27
1I am using geth– LismoreDec 19, 2017 at 12:28
Have a look in
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
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.
1Thanks Richard, that's more than enough to continue my research.– LismoreDec 19, 2017 at 12:39
1No problem - enjoy :-) Dec 19, 2017 at 12:40
@Lismore Did you discover how to do this? Feb 8, 2018 at 15:30