1

Orphan block is a block that doesn't have a known parent in the longest block chain.

As I understand, this mean that orphaned block does not have a reference on it as "previous block hash" in any newest block. It is correct?

If yes, I make some research and does not understand why I get some strange results.

So, I extract all block hashes from raw dat files. Then I extract all "previous block hash" data from raw dat files. As a result I've got 2 arrays: block hashes (array A) and parent references (array B). Then if I subtract B from A, I would get a list of orphaned blocks.

Is it right way to get orphaned block list, or not?

P.S. I get this results after parsing dat files from blk00000.dat to blk00953.dat (I chose two blocks from the compiled list):

000000000000000003D57B69D1AC77F64287C893C16ADBC1816C6D7386CCC3C0 – orphaned 0000000000000000011523D7477DD274B7E0DCC2C616B2E2F584FFDEC20237D3 - main chain

main chain and orphaned are the status based on block explorer sites.

On this two blocks does not any reference as "previous" in raw dat files. I'am confused – "why?"

  • The term 'orphan block' was commonly used for at least two very different things: see bitcoin.stackexchange.com/a/5869/208. It seems you're referring to the second meaning here, which is not relevant anymore. Since the introduction of headers-first sync, no such orphans exist anymore. – Pieter Wuille Jun 30 '17 at 6:17
  • @PieterWuille thank's for help) But the first block from my example was mined 2016-11-29 (after release bitcoin core v0.10) and this block is in dat file that on disk \blocks dir – Denis Leonov Jun 30 '17 at 6:49
  • Block explorer websites use the term 'orphaned' to mean "no longer in the main chain", not "no known parent". – Pieter Wuille Aug 22 '17 at 4:03
  • here is about the blocks that has no references after. I'v got em. – Denis Leonov Aug 24 '17 at 0:13
1

As a result I've got 2 arrays: block hashes (array A) and parent references (array B). Then if I subtract B from A, I would get a list of orphaned blocks.

No, doing that will get you a list of stale blocks (which are commonly referred to as orphaned blocks). What you are doing is getting all blocks which are not parents of anything, not blocks which do not have parents.

000000000000000003D57B69D1AC77F64287C893C16ADBC1816C6D7386CCC3C0 – orphaned 

The term "orphaned" here means that the block does not have any children. This is the second meaning of the term "orphaned block". This result is expected since you are removing from your list of block hashes the list of parent blocks, and this block is not a parent.

0000000000000000011523D7477DD274B7E0DCC2C616B2E2F584FFDEC20237D3 - main chain

This block is in the main chain. It is probably in your list because that is what your node was synced up to and this was its most recent block.

  • I think my English is not so good. I mean that every block have reference on previous, but for example in blk00234.dat present block that has no reference on it in whole database. This block calls orphaned. Is it true? – Denis Leonov Aug 22 '17 at 18:28
  • blocks can come to your node not in right order, so, it is possible to have a block without parent in your local storage – amaclin Aug 22 '17 at 18:37
  • Yes, a block which has no children is commonly referred to as orphaned. But that is not the definition of orphaned that you are using. – Andrew Chow Aug 22 '17 at 18:38
  • (...but for example in blk00234.dat...) the mainchain is equal on all nodes, but blk-files are not byte-to-byte equal to each other. your version has orphan block in file #234, mine does not have – amaclin Aug 22 '17 at 18:40
  • @amaclin so you tell that a full bitcoin database (\blocks\blk*.dat files) is not equal for all who install bitcoin client? – Denis Leonov Aug 22 '17 at 18:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.