Since miners are also nodes at the same time, they should be capable of sending transactions. So the question is, can they mine their own transaction technically? And if yes, are they allowed to do do? If yes, a miner will surely have maximum advantage on his own transaction and he should be able to mine it with a success rate of 100% and way faster than any other miner on the network. This defeats the concept of consensus.
Transaction Mining – Can Miners Mine Their Own Transactions?
miningtransactions
Related Solutions
As I mentioned in the answer to the post you've referenced, putting your own transactions into a block doesn't make that block easier to mine. You'd still be competing against the rest of the miners, who may or may not have included your low-priced transaction in the block they're mining. You'd probably1 be better off broadcasting the transaction and hoping someone else - perhaps with far greater hashing power than you - picks it up. (i.e. Use the power of the rest of the network rather than cutting yourself off from it.)
To actually answer your question though, there are a couple of options I can think of. (Other people may have other ideas.)
- If you're using the Parity client, use the
--tx-queue-strategy
flag to prioritise low priced transactions. (Though this won't guarantee yours is included if the transaction pool is full of cheap transactions.) I think the same can be done with the--gasprice
option. Geth doesn't have a way to set maximum limits for gas price, only minimum limits, so you can't prioritise low prices. - The only way I can see to guarantee that your own transactions are prioritised is to edit the code. For Geth, I've mentioned where transactions from the memory pool are sorted in this previous answer. You'd need to inspect the
from
address in each transaction, and only add to the block you're mining if the address is yours. (I think. There might be an easier way of creating a local transaction pool containing only your transactions, but that would need some digging and design.)
1 I've no way of quantifying this...
Why shouldn't I set up a miner account, which would mine only transactions with the lowest gas-price possible - 1 wei?
Yep, you can, but...
Should some other miner catch them first (for some odd reason, because who would want to work for such a low price), I will end up paying 1 wei to that miner.
For any given block, the rest of the network will (most likely) be prioritising transactions with the highest available gas prices. You will be competing against the rest of the network for that given block. Unless you can throw enough hashing power behind finding the PoW for the block you've constructed yourself, someone out there will beat you to it (for their version of the same block). You then have start over again, constructing the next-numbered block with your low-priced transactions.
Best Answer
When a miner creates a block, he can put whatever transactions into that block that he likes, including his own1.
However, creating the block locally and populating it with transactions, and then successfully mining it, are two different things.
For the block to be mined it must contain a valid proof of work, which proves to the network that the node has solved a computationally difficult problem. The difficulty of this problem is in no way related to the transactions the miner has decided to put into the block. It isn't any easier to mine a block containing your own transactions - the difficulty comes from elsewhere.
1The current vanilla Geth code prioritises transactions in a certain way, but a miner can edit the code in any way he likes to prioritise things differently.