<p>Headers-first sync is defined somewhat by <a href="https://github.com/bitcoin/bips/blob/master/bip-0130.mediawiki" rel="nofollow noreferrer">BIP 130</a> and expanded upon with <a href="https://github.com/bitcoin/bips/blob/master/bip-0152.mediawiki" rel="nofollow noreferrer">compact block relay in BIP 152</a>. I believe <a href="https://github.com/bitcoin/bitcoin/commit/341735e" rel="nofollow noreferrer">this</a> is the commit in which it was added to Bitcoin Core.</p>

<p>The result is that Bitcoin Core nodes never send <code>getblocks</code> messages anymore, they get headers first with <code>getheaders</code>, then after some verification, they request full blocks with <code>getdata</code>.</p>

<p>My question is, do SPV nodes need to follow this scheme as well? They certainly could, they'd just open the peer connection with a <code>filterload</code> so when they <code>getdata</code> they get <code>merkleblock</code> messages back instead of full <code>block</code> or <code>cmpctblock</code> messages.</p>

<p>This is an implementation-specific question, but I am actually hoping for examples. For one, <a href="https://github.com/breadwallet/breadwallet-core/blob/8eb05454df3e2d5cca248b4e24eeffa420c97e3a/bitcoin/BRPeer.c#L59-L85" rel="nofollow noreferrer">Breadwallet seems to have a custom network protocol</a> in which both <code>getheaders</code> and <code>getblocks</code> are used.</p>

<p>Are there any other examples of SPV applications using <code>getheaders</code> and <code>getblocks</code> in this way?</p>

<p>Do most SPV clients just use <code>getblocks</code> or do they try to sync headers-first, even though they'll never request full blocks?</p>

CC BY-SA 4.0
2019-04-19T17:23:19.823Z
headers-first sync is a local strategy, and it was implemented by Bitcoin Core before BIP130; that BIP just reduces the number of messages exchanges when announcing a new block. And nobody "needs" to follow this scheme; I believe it's superior, but there is no authority to tell you in what way to use the protocol as long as it's not damaging to others.
Pieter Wuille
CC BY-SA 4.0
2019-04-19T17:43:32.673Z
@PieterWuille Thanks, I might be asking more for advice on "best practices" -- if I were implementing a new SPV node, would headers first still be the superior strategy?
pinhead
<network><synchronization><spv>
Do SPV nodes sync "headers-first"?
pinhead
# Do SPV nodes sync "headers-first"?

(Asked by: username_0 on 2019-04-19)

Headers-first sync is defined somewhat by [BIP 130](https://github.com/bitcoin/bips/blob/master/bip-0130.mediawiki) and expanded upon with [compact block relay in BIP 152](https://github.com/bitcoin/bips/blob/master/bip-0152.mediawiki). I believe [this](https://github.com/bitcoin/bitcoin/commit/341735e) is the commit in which it was added to Bitcoin Core.

The result is that Bitcoin Core nodes never send `getblocks` messages anymore, they get headers first with `getheaders`, then after some verification, they request full blocks with `getdata`.

My question is, do SPV nodes need to follow this scheme as well? They certainly could, they'd just open the peer connection with a `filterload` so when they `getdata` they get `merkleblock` messages back instead of full `block` or `cmpctblock` messages.

This is an implementation-specific question, but I am actually hoping for examples. For one, [Breadwallet seems to have a custom network protocol](https://github.com/breadwallet/breadwallet-core/blob/8eb05454df3e2d5cca248b4e24eeffa420c97e3a/bitcoin/BRPeer.c#L59-L85) in which both `getheaders` and `getblocks` are used.

Are there any other examples of SPV applications using `getheaders` and `getblocks` in this way?

Do most SPV clients just use `getblocks` or do they try to sync headers-first, even though they'll never request full blocks?

**Tags:** network, synchronization, spv

> **Comments:**
> **username_1**: headers-first sync is a local strategy, and it was implemented by Bitcoin Core before BIP130; that BIP just reduces the number of messages exchanges when announcing a new block. And nobody "needs" to follow this scheme; I believe it's superior, but there is no authority to tell you in what way to use the protocol as long as it's not damaging to others.  
> **username_0**: @username_1 Thanks, I might be asking more for advice on "best practices" -- if I were implementing a new SPV node, would headers first still be the superior strategy?  

---

## 0 answers

