3

I understand it's in the miner's best interest to receive as many fees as possible for his hopefully-accepted block, hence it should include the most rewarding (fee / size) txs - up to the 1MB limit.

However, what algorithm do the miners use? It seems like a knapsack problem, which is NP-Hard, so I doubt miners actually go for the optimal solution.

Thanks!

1

No. this is not knapsack problem and no one need to find optimal solution.

Sort your transactions in mempool by two rules:

  • subsequent transactions can not be to the left of parent ones
  • most profitable transactions (fee/size) gravitate to left

and take leftmost transactions from mempool until 1 mb limit

  • Great, thanks. Where can I find the code that implements this behavior? – Itay Nov 2 '17 at 12:22
  • somewhere in github.com/bitcoin/bitcoin (cy, Captain Obvious) – amaclin Nov 2 '17 at 12:43
  • 1
    this isnt the full truth, and miners likely differ in their implementations. one way to prove this isnt the full truth is to look at the existence of transactiln accelerators, another to look at blocks with 0 transactions and a third to look at blocks with some transaction types excluded. – Jonathan Silverblood Nov 3 '17 at 7:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.