Bitcoin Forum
May 24, 2024, 05:34:36 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: What is binary format blk00NNN.dat files  (Read 887 times)
Frodek (OP)
Member
**
Offline Offline

Activity: 138
Merit: 25


View Profile
May 06, 2016, 06:43:33 PM
 #1

Blocks are described here : https://en.bitcoin.it/wiki/Block
There are chains of blocks , summary size < 128 MiB?
achow101
Moderator
Legendary
*
Offline Offline

Activity: 3402
Merit: 6653


Just writing some code


View Profile WWW
May 06, 2016, 06:58:59 PM
 #2

The blocks are written to the disk exactly in the way that Bitcoin Core receives them. It just writes the actually block messages. What exactly are you asking?

Frodek (OP)
Member
**
Offline Offline

Activity: 138
Merit: 25


View Profile
May 06, 2016, 07:36:31 PM
Last edit: May 06, 2016, 07:52:08 PM by Frodek
 #3

If I must read  specific block for example 200000, in which file and which position in this file this block begin?
I must read indices, where described is indices format?
In https://en.bitcoin.it/wiki/Block I can't see block heights
I can't see block hash, only previous hash.
In blockchain are also blocks from alternative branch?
achow101
Moderator
Legendary
*
Offline Offline

Activity: 3402
Merit: 6653


Just writing some code


View Profile WWW
May 06, 2016, 07:56:41 PM
 #4

If I must read  specific block for example 200000, in which file and which position in this file this block begin?
I must read indices, where described is indices format?
In https://en.bitcoin.it/wiki/Block I can't see block heights
I can't see block hash, only previous hash.
In blockchain are also blocks from alternative branch?

The indices for the blocks are in a separate LevelDB database. The blk*.dat files are simply where the blocks are stored, but it means nothing to the software without the database which indexes the blocks. Those indices are kept in the index folder inside of the blocks folder. Bitcoin Core will write to the disk every valid block it receives, so this does include forks and stale blocks in case of blockchain reorgs.

Frodek (OP)
Member
**
Offline Offline

Activity: 138
Merit: 25


View Profile
May 06, 2016, 08:12:30 PM
 #5

Is where description of indices files? I must maybe use https://github.com/google/leveldb to read.
achow101
Moderator
Legendary
*
Offline Offline

Activity: 3402
Merit: 6653


Just writing some code


View Profile WWW
May 06, 2016, 08:45:33 PM
 #6

Is where description of indices files? I must maybe use https://github.com/google/leveldb to read.
There is no description of the format of leveldb files that I know of. You will have to write your own client which uses LevelDB in order to read the data from those db files.

Frodek (OP)
Member
**
Offline Offline

Activity: 138
Merit: 25


View Profile
May 07, 2016, 04:15:01 AM
 #7

Maybe is possible to avoid reading indices?
I first read headers of all block, next I compute hash (how fields use specifically to compute hash besides nonce?, next I will build chain tree and select the longest chain.
achow101
Moderator
Legendary
*
Offline Offline

Activity: 3402
Merit: 6653


Just writing some code


View Profile WWW
May 07, 2016, 04:24:51 AM
 #8

Maybe is possible to avoid reading indices?
I first read headers of all block, next I compute hash (how fields use specifically to compute hash besides nonce?, next I will build chain tree and select the longest chain.

Sure, you can do it that way too. Each block is the 4 byte magic bytes, then the size of the block, then the block in raw format. The first 80 bytes is the header and that is hashed using sha256d. The output is then represented using little endian. The rest of the block is just the transactions. For full info on the serialized format, see https://bitcoin.org/en/developer-reference#serialized-blocks

Frodek (OP)
Member
**
Offline Offline

Activity: 138
Merit: 25


View Profile
May 07, 2016, 05:04:22 AM
 #9

I can not understand how to obtain multiple leading zeros in hash, while nonce is only 32-bit value
Miners manipulates hash of Merkle tree?
shorena
Copper Member
Legendary
*
Offline Offline

Activity: 1498
Merit: 1520


No I dont escrow anymore.


View Profile WWW
May 07, 2016, 06:46:37 AM
 #10

I can not understand how to obtain multiple leading zeros in hash, while nonce is only 32-bit value
Miners manipulates hash of Merkle tree?

Yes, the merkle tree is indirectly "manipulated" by adding or removing transactions. The timestamp and the coinbase input can also be modified.

Im not really here, its just your imagination.
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!