This is by no means ready, but anyhow this builds on #7756 and
- Adds a streaming API to the HTTP server. This allows streaming data to the client chunk by chunk, which is useful when not the entire data is available at once or it is huge and wouldn’t fit (efficiently) in memory.
- Allows downloading the entire UTXO set through
/rest/utxoset
. This is a raw dump of all outputs, the state normally hashed bygettxoutsetinfo
. The dump is performed in the background by making use of leveldb snapshotting, so without keeping cs_main locked.- This can be useful for analysis purposes if you don’t want to mess with bitcoin core’s database
- Filename (via content-disposition) is
utxoset-<height>-<bestblockhash>.dat
. Also a customX-Best-Block
andX-Block-Height
header is added.
It matches:
0$ src/bitcoin-cli -datadir=/store/tmp/testbtc gettxoutsetinfo
1{
2...
3 "hash_serialized": "5017f82bbb82a8199ae0fbaa9e5881a0c82575db89e6edd5b39414b35299363b",
4...
5}
6$ wget --content-disposition http://127.0.0.1:8332/rest/utxoset
72016-03-28 22:58:32 (44.3 MB/s) - ‘utxoset-404681-0000000000000000034854f5a3ab27cfbc220a42c75061dd13d2067cda71191d.dat’ saved [1291578967]
8$ ~/bin/dsha256 utxoset-404681-0000000000000000034854f5a3ab27cfbc220a42c75061dd13d2067cda71191d.dat
95017f82bbb82a8199ae0fbaa9e5881a0c82575db89e6edd5b39414b35299363b utxoset
TODO
Rebase after #7756 merged- Sensibly name and split up commits
- Clean up and split up code
- Actually handle errors (you can crash a worker thread right now by disconnecting while downloading)
- The timeout actually runs while downloading, causing it to break off after downloading. I don’t understand why this is. You can work around it with
-rpcservertimeout=6000
or such. UTXO set dump doesn’t contain keys (?) I’m not sure this format is actually useful this way (see #7758)(fixed in #7848)- Other formats, potentially ^^
Note that the HTTP streaming API could in principle also be used for other large data (say, wallet backups), or even for websocket-like event notification.