<p>The whole mempool won't fit in a block; <code>getblocktemplate</code> returns enough transactions for a block. Blocks are, by default, <a href="https://github.com/bitcoin/bitcoin/blob/a6a860796a44a2805a58391a009ba22752f64e32/src/policy/policy.h#L18" rel="noreferrer">limited to 750kb by policy</a>, but many miners increase the size to the block limit of 1mb (which can be done by command-line flag).</p>

<p>The specific piece of code that decides on the transactions that should be included in a block <a href="https://github.com/bitcoin/bitcoin/blob/86b800c6a299455580fe76e5fb43218f0222e179/src/miner.cpp#L113" rel="noreferrer">can be found here</a>. It's reasonably well documented, and not terrible to read, I'd suggest taking a look through it to see where your script operates differently.</p>

CC BY-SA 3.0
2016-05-22T13:31:13.400Z
2016-05-22T13:31:13.400Z
fluffyponyza
<p>I wrote a script that compares the transactions listed in the <strong>memory pool</strong> with the transactions included in <code>getblocktemplate</code>:</p>

<p><a href="http://learnmeabitcoin.com/explorer/node/memorypool" rel="nofollow">http://learnmeabitcoin.com/explorer/node/memorypool</a></p>

<p><em>(I've ordered the transactions by [current priority], and highlighted the ones included in <code>getblocktemplate</code> in blue.)</em></p>

<ul>
<li><p>How does <code>getblocktemplate</code> choose which transactions to include from the memory pool in a candidate block?</p></li>
<li><p>Why aren't transactions being selected from highest to lowest priority?</p></li>
</ul>

<transaction-selection><getblocktemplate><coin-age-priority>
How does getblocktemplate select transactions?
inersha
# How does getblocktemplate select transactions?

(Asked by: username_0 on 2016-05-22)

I wrote a script that compares the transactions listed in the **memory pool** with the transactions included in `getblocktemplate`:

<http://learnmeabitcoin.com/explorer/node/memorypool>

*(I've ordered the transactions by [current priority], and highlighted the ones included in `getblocktemplate` in blue.)*

* How does `getblocktemplate` choose which transactions to include from the memory pool in a candidate block?
* Why aren't transactions being selected from highest to lowest priority?

**Tags:** transaction-selection, getblocktemplate, coin-age-priority


---

## 1 answers

### Answer by username_1 on 2016-05-22. Score: 5 | Accepted answer

The whole mempool won't fit in a block; `getblocktemplate` returns enough transactions for a block. Blocks are, by default, [limited to 750kb by policy](https://github.com/bitcoin/bitcoin/blob/a6a860796a44a2805a58391a009ba22752f64e32/src/policy/policy.h#L18), but many miners increase the size to the block limit of 1mb (which can be done by command-line flag).

The specific piece of code that decides on the transactions that should be included in a block [can be found here](https://github.com/bitcoin/bitcoin/blob/86b800c6a299455580fe76e5fb43218f0222e179/src/miner.cpp#L113). It's reasonably well documented, and not terrible to read, I'd suggest taking a look through it to see where your script operates differently.


---

