<p>Currently-released version of Bitcoin Core will only process blocks sequentially starting from the beginning of the chain.  If that happens to be the beginning of your epoch, you can start recent versions of bitcoind with the <code>-stopatheight</code> parameter to specify the end of your epoch and bitcoind will stop downloading blocks at that point.</p>

<p>Alternatively, a pending Bitcoin Core pull request (PR) provides the behavior you want where you can tell Bitcoin Core not to download any blocks automatically and then manually specify which blocks you want.  See <a href="https://github.com/bitcoin/bitcoin/pull/10794" rel="nofollow noreferrer">PR#10794</a> for details.</p>

<p>Note that if you operate in this mode connected directly to the peer-to-peer network, your node will only have SPV-level security, meaning someone could theoretically give your node an invalid block with a valid amount of proof of work.  If you require a high degree of security, it would be recommend that you exclusively connect your bitcoind running PR#10794 to one of your own fully-validating (regular) bitcoind nodes so that will ensure you only receive valid blocks.  To do that, see the <code>-connect</code> option to bitcoind.</p>

CC BY-SA 4.0
2018-05-02T08:59:54.717Z
2018-05-02T08:59:54.717Z
David A. Harding
<p>You could use the pruning mode to only store blocks after the height you are interested in. I think you'll still have to download it to verify the past history, but you won't have to store it all on disk. </p>

<p>See this <a href="https://bitcoin-rpc.github.io/pruneblockchain.html" rel="nofollow noreferrer">RPC call</a> for more information.</p>

CC BY-SA 4.0
2018-05-02T08:59:05.507Z
2018-05-02T08:59:05.507Z
alcio
<p>This is implemented with <a href="https://github.com/bitcoin/bitcoin/pull/20295" rel="nofollow noreferrer">pull request &quot;rpc: <strong>getblockfrompeer</strong>&quot; #20295</a>, merged into <code>master</code> on Dec 8, 2021:</p>
<blockquote>
<p><a href="https://bitcoincore.org/en/doc/27.0.0/rpc/blockchain/getblockfrompeer/" rel="nofollow noreferrer"><strong>getblockfrompeer</strong></a> &quot;blockhash&quot; peer_id</p>
<p>Attempt to fetch block from a given peer.</p>
<p>We must have the header for this block, e.g. using submitheader.
Subsequent calls for the same block may cause the response from the
previous peer to be ignored. Peers generally ignore requests for a
stale block that they never fully verified, or one that is more than a
month old. When a peer does not respond with a block, we will
disconnect. Note: The block could be re-pruned as soon as it is
received.</p>
<p>Returns an empty JSON object if the request was successfully
scheduled.</p>
<p>Arguments:</p>
<ol>
<li>blockhash    (string, required) The block hash to try to fetch</li>
<li>peer_id      (numeric, required) The peer to fetch it from (see getpeerinfo for peer IDs)</li>
</ol>
<p>Result: {}    (empty JSON object)</p>
<p>Examples:</p>
<blockquote>
<p>&gt; bitcoin-cli getblockfrompeer &quot;00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09&quot; 0</p>
<p>&gt; curl --user myusername --data-binary '{&quot;jsonrpc&quot;: &quot;1.0&quot;, &quot;id&quot;: &quot;curltest&quot;, &quot;method&quot;: &quot;getblockfrompeer&quot;, &quot;params&quot;:
[&quot;00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09&quot;
0]}' -H 'content-type: text/plain;' <a href="http://127.0.0.1:8332/" rel="nofollow noreferrer">http://127.0.0.1:8332/</a></p>
</blockquote>
</blockquote>

CC BY-SA 4.0
2024-05-18T21:12:13.853Z
2024-05-18T21:12:13.853Z
Geremia
<p>My dev environment is quite limited in terms of bandwidth and storage. I need to make a database out of transactions containing opcode 0x6a since a given epoch.</p>

<p>[Scan blocks, going backwards from the latest, until a given blockheight]<br>
[If the transaction outputs contain OP_RETURN, save it with associated metadata]</p>

<p>Is there a way I can do this with bitcoind without having to store the entire chain?</p>

<bitcoind>
How do I download specific blocks directly from peers, without downloading the entire chain?
boysimple dimple
# How do I download specific blocks directly from peers, without downloading the entire chain?

(Asked by: username_0 on 2018-05-02)

My dev environment is quite limited in terms of bandwidth and storage. I need to make a database out of transactions containing opcode 0x6a since a given epoch.

[Scan blocks, going backwards from the latest, until a given blockheight]  
[If the transaction outputs contain OP\_RETURN, save it with associated metadata]

Is there a way I can do this with bitcoind without having to store the entire chain?

**Tags:** bitcoind


---

## 3 answers

### Answer by username_1 on 2018-05-02. Score: 1

Currently-released version of Bitcoin Core will only process blocks sequentially starting from the beginning of the chain. If that happens to be the beginning of your epoch, you can start recent versions of bitcoind with the `-stopatheight` parameter to specify the end of your epoch and bitcoind will stop downloading blocks at that point.

Alternatively, a pending Bitcoin Core pull request (PR) provides the behavior you want where you can tell Bitcoin Core not to download any blocks automatically and then manually specify which blocks you want. See [PR#10794](https://github.com/bitcoin/bitcoin/pull/10794) for details.

Note that if you operate in this mode connected directly to the peer-to-peer network, your node will only have SPV-level security, meaning someone could theoretically give your node an invalid block with a valid amount of proof of work. If you require a high degree of security, it would be recommend that you exclusively connect your bitcoind running PR#10794 to one of your own fully-validating (regular) bitcoind nodes so that will ensure you only receive valid blocks. To do that, see the `-connect` option to bitcoind.


---

### Answer by username_2 on 2018-05-02. Score: 1

You could use the pruning mode to only store blocks after the height you are interested in. I think you'll still have to download it to verify the past history, but you won't have to store it all on disk.

See this [RPC call](https://bitcoin-rpc.github.io/pruneblockchain.html) for more information.


---

### Answer by username_3 on 2024-05-18. Score: 0

This is implemented with [pull request "rpc: **getblockfrompeer**" #20295](https://github.com/bitcoin/bitcoin/pull/20295), merged into `master` on Dec 8, 2021:

> [**getblockfrompeer**](https://bitcoincore.org/en/doc/27.0.0/rpc/blockchain/getblockfrompeer/) "blockhash" peer\_id
>
> Attempt to fetch block from a given peer.
>
> We must have the header for this block, e.g. using submitheader.
> Subsequent calls for the same block may cause the response from the
> previous peer to be ignored. Peers generally ignore requests for a
> stale block that they never fully verified, or one that is more than a
> month old. When a peer does not respond with a block, we will
> disconnect. Note: The block could be re-pruned as soon as it is
> received.
>
> Returns an empty JSON object if the request was successfully
> scheduled.
>
> Arguments:
>
> 1. blockhash (string, required) The block hash to try to fetch
> 2. peer\_id (numeric, required) The peer to fetch it from (see getpeerinfo for peer IDs)
>
> Result: {} (empty JSON object)
>
> Examples:
>
> > > bitcoin-cli getblockfrompeer "00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09" 0
> >
> > > curl --user myusername --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "getblockfrompeer", "params":
> > ["00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09"
> > 0]}' -H 'content-type: text/plain;' <http://127.0.0.1:8332/>


---

