<p>There isn't even a database lookup in Bitcoin Core. All blocks and mempool transactions are indexed by hash in memory. It's typically just serializing from memory, or one disk read directly sending disk data to the network.</p>

CC BY-SA 4.0
2019-03-04T18:19:01.543Z
2019-03-04T18:19:01.543Z
Pieter Wuille
<p>I am confused about how getdata() is actually implemented at full nodes.</p>

<p>Suppose a full node receives a getdata() request with MSG_BLOCK flag and a hash H of some block B. Then would it simply look up H into its levelDB database to fetch B from its disk and return it to the caller (in constt time) or something more expensive is done?</p>

<p>Can I also get some references to read about it?</p>

<bitcoin-core><bitcoind><client><full-node><implementation>
Implementation of getdata
archita
# Implementation of getdata

(Asked by: username_0 on 2019-02-28)

I am confused about how getdata() is actually implemented at full nodes.

Suppose a full node receives a getdata() request with MSG\_BLOCK flag and a hash H of some block B. Then would it simply look up H into its levelDB database to fetch B from its disk and return it to the caller (in constt time) or something more expensive is done?

Can I also get some references to read about it?

**Tags:** bitcoin-core, bitcoind, client, full-node, implementation


---

## 1 answers

### Answer by username_1 on 2019-03-04. Score: 1

There isn't even a database lookup in Bitcoin Core. All blocks and mempool transactions are indexed by hash in memory. It's typically just serializing from memory, or one disk read directly sending disk data to the network.


---

