Hi everyone,
I'm trying to optimize the blockchain files.
What I found is interesting.
So for one thing is obvious - protocol is not optimized.
Why?
Well you have distinctive lengths IN the protocol description, and for some reason you still need the block length AND the delimiter (not to mention that the lock time might as well be a delimiter).
But first things first, the only descriptive information about the blocks I found is in this page
http://james.lab6.com/2012/01/12/bitcoin-285-bytes-that-changed-the-world/But it does not state the format of target bits field is it a varint or just a regular 4byte int?
For now you can safely delete the fields of of network id in the blockchain data as well as block length, sequence number and lock time.
Save the timestamp as difference from previous block - this can yield additional optimisation for 4 bytes in keys.
That frees just 16 bytes per block which is not too much, but I want to delve deeper into relations in the script of bitcoin transaction so we can build a relation database first to see how everything is connected and then just optimize by the lower numbered sequence of keys (the latter is obvious various hashes).
I'm doing this for fun, and not sure a drastic optimization can be done, but it's funny that no comprehensive network protocol and file format description exists in the wild.
The nBits is a compressed form of the target, it's of type uint32_t, which on my own system is 4 bytes.
https://en.bitcoin.it/wiki/Protocol_specification#Block_Headers