bitcoin core improvement – what’s the mapBlocksUnknownParent variable?

0
80
bitcoin core improvement – what’s the mapBlocksUnknownParent variable?


  1. What’s the mapBlocksUnknownParent variable? The place is it helpful?

It retains a map of blocks within the blk*.dat recordsdata whose mother or father is unknown, listed by the block hash of that mother or father.

  1. What does LoadExternalBlockFile perform do? (by its identify I deduce that it reads blk???.dat recordsdata and cargo them into the reminiscence firstly up. However I am unsure)

It offers with importing blocks from exterior recordsdata. This implies not from the community, and never blocks already in our block database. It occurs in two contexts:

  • When a file is specified on the command line utilizing -loadblock=<FILE>; this can be utilized to import blocks e.g. given to you on transportable media (say, a USB stick).
  • When operating with -reindex, during which case the block database is wiped, however the blk*.dat recordsdata are stored, after which this “importing” operation is run on these nonetheless current blk*.dat recordsdata.
  1. When is it doable to have blocks with unknown dad and mom? Whereas AFAIK we at all times attain blocks by means of their ancestors, not descendants. So during which state of affairs now we have a block with unknown mother or father?

When requesting blocks from the community, we solely ask for blocks whose dad and mom are identified (a minimum of the headers have to be identified), so certainly, this variable is not helpful in that context. However the blocks should not downloaded so as, and the blk*.dat recordsdata include blocks within the order they have been obtained.

Which means when utilizing -reindex to rebuild the database, some blocks might be encountered out-of-order, which means blocks might be learn whose mother or father is not identified but. To take care of this case, LoadExternalBlockFile retains monitor of those blocks with out identified mother or father. When the mother or father is encountered and processed, the youngsters might be processed too.

  1. Why this variable is taken into account world whereas it’s outlined within a perform scope? Is that this as a result of the variable is static?

Precisely. static variables in perform scopes are successfully globals that may solely be accessed from that perform. Just one occasion of the variable exists, shared between all invocations of that perform.

LEAVE A REPLY

Please enter your comment!
Please enter your name here