I am doing some investigation related to the bitcoin transactions graph and I don't need the whole blockchain, because it would be too much data (and I don't have much space). I just need a part of the blockchain to construct a graph with the transactions and then do some analysis on it. Is it possible to download only a part of the blockchain? Let's say I want only up to 3 million transactions. Or something like the transactions from 2015 and 2016, or the most recent 3 million transactions (these are not requirements I have on the data, it's just to exemplify).
1 Answer
If you write software yourself, with a custom implementation of the P2P protocol, this is certainly possible. Just send getdata
messages for just the blocks in the range you want.
No such feature exists in Bitcoin Core however, as its purpose is fully verifying the state of the chain, it will always start at the very beginning. If you want blocks somewhere from 2015 you can of course just stop the software once it has passed that point.
Note that Bitcoin Core does support a pruned mode, in which only the last N blocks are kept on disk (but they're still all downloaded and verified, just discarded after verification). If you want access to the last 3000000 transactions, and lack diskspace for the full chain, it would be an option to synchronize in pruned mode.
-
I will investigate those getdata messages. I am new in the bitcoin technology so I did not know you could just send messages for specific blocks. Could I do that also to ask for some transactions? I think the idea could be to start from a random transaction and ask for the previous and the previous and so on. A problem I have with using Bitcoin Core is that my PC is not very powerful, so I guess it could take too much time to download and verify the blockchain, even if I use pruned mode.– KareitNov 19 at 13:06
-
1The P2P protocol does allow asking for specific transactions, but it's only for transactions the peer has recently announced to you. Nodes do not generally keep a database of all transactions ever that you can just query, as it's not needed for general operation, so even nodes which do have such an index do not expose it through P2P commands. Nov 19 at 13:10