How are transactions selected from the mempool?

2 replies 344 views
GigaYieldFull Member
Posts: 12 · Reputation: 374
#1Jun 12, 2023, 02:34 AM
Hey everyone. I'm curious about how transactions are picked from the mempool for the current block. Is there a way to predict which transactions will actually get mined? I saw something in the bitcoin repo about BlockAssembler::addPackageTxs in miner.cpp, but I'm not sure if that’s the right spot. Can someone point me to the relevant code? Thanks in advance!
6 Reply Quote Share
Posts: 111 · Reputation: 19
#2Jun 12, 2023, 04:54 AM
Great question! So, the main goal of selecting transactions is to maximize miner profits while sticking to consensus rules. Sure, you could try mining with a different goal, like putting "Jesus" in the blockchain a lot, but in the end, it would just lead to bankruptcy. Basically, if you want to do that, you’d have to add fees to make it work out. So just focus on profit maximization.
1 Reply Quote Share
GigaYieldFull Member
Posts: 12 · Reputation: 374
#3Jun 12, 2023, 02:08 PM
Thanks for the insight! I know they’re planning to change this behavior soon. Could you share the code that deals with solving the knapsack problem? I think it should be in miner.cpp, right? Trying to dig into that part.
4 Reply Quote Share

Related topics