Any idea how to download a small part of the chain for testing purposes?
Any idea how to download a small part of the chain for testing purposes?
I am experimenting with Python and Rust libraries on my laptop. I don't actually want to get a node going on it and download the full chain; I just need some blocks to play with.
I want to keep my question general enough though; what is the easiest way for someone to download just a small portion of the blockchain, given specific beginning and end points in block numbers? Are there any libraries that would do that either in Python, JS, or Rust (or any other languages, so my question applies to all developers)?
2 Answers
2
If you know what hashes of the blocks you want, you can use the P2P protocol to connect to a node and request those specific blocks. However, you cannot just do that with block heights as the block's height is not a unique identifier for the block. There are many libraries available that can speak the P2P protocol. The python-bitcoinlib can be used to send the P2P messages necessary for doing this.
As far as I know, there is no way to download arbitrary blocks (although I suspect it's not too hard to do if you implement your own client).
If you just want blocks for testing, you won't have much trouble finding bootstrap.dat
s that contain a few hundred thousand blocks. Alternatively, you could just run bitcoin core for half an hour or so and get a few thousand blocks from the start of the chain - The early blocks are mostly empty and download pretty quick.
bootstrap.dat
Thanks for contributing an answer to Bitcoin Stack Exchange!
But avoid …
To learn more, see our tips on writing great answers.
Required, but never shown
Required, but never shown
By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy