Bitcoin Forum
November 05, 2024, 07:54:25 AM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: ///////////////////////////////////////////////////  (Read 1049 times)
Ikinoki (OP)
Newbie
*
Offline Offline

Activity: 6
Merit: 100


View Profile
December 03, 2013, 02:57:10 AM
Last edit: May 31, 2020, 04:15:05 PM by Ikinoki
 #1

H//////////////////////////////////////////////////

Donations to 1LHTGFYHfMDgfgmDcYugW6RsKKfKBRfLVg
Remember remember the 5th of November
Legendary
*
Offline Offline

Activity: 1862
Merit: 1011

Reverse engineer from time to time


View Profile
December 03, 2013, 03:45:30 AM
 #2

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

BTC:1AiCRMxgf1ptVQwx6hDuKMu4f7F27QmJC2
moderate
Member
**
Offline Offline

Activity: 98
Merit: 10

nearly dead


View Profile
December 03, 2013, 04:04:40 AM
 #3


The nBits is a compressed form of the target, it's of type uint32_t, which on my own system is 4 bytes.


Are you implying there is some real word system, running today, where 8 bits != 1 byte ? Does it run bitcoin too ?
danneu
Newbie
*
Offline Offline

Activity: 32
Merit: 0



View Profile
December 03, 2013, 06:11:26 AM
 #4

blk*.dat format is a repetition of:

- magic (uint32-le)
- size  (uint32-le) - bytes count of following block
- block (https://en.bitcoin.it/wiki/Protocol_specification#block)

The block spec points out that `bits` is a uint32-le.

`bits` represents difficulty in compact form and you can see how to expand it here https://en.bitcoin.it/wiki/Difficulty.

Quote
but it's funny that no comprehensive network protocol and file format description exists in the wild.

The wiki (https://en.bitcoin.it/wiki/Protocol_specification) is pretty comprehensive.
bitspill
Legendary
*
Offline Offline

Activity: 2087
Merit: 1015



View Profile
January 09, 2014, 03:01:15 PM
 #5

The nBits is a compressed form of the target, it's of type uint32_t, which on my own system is 4 bytes.
Are you implying there is some real word system, running today, where 8 bits != 1 byte ? Does it run bitcoin too ?
http://en.wikipedia.org/wiki/Byte#Common_uses
http://stackoverflow.com/questions/5516044/system-where-1-byte-8-bit/5516161#5516161


{ BitSpill }
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!