blk file error when reading - did something change in the format? #11736

issue mrqc openend this issue on November 20, 2017
  1. mrqc commented at 4:03 pm on November 20, 2017: none

    I am reading blkXXX.dat files. I am facing the problem that in my blk00970.dat I can read at some position the magicNumber of the block. but the block is empty because after that the magicNumber is again contained in the file which should be the version.

    workaround: if version == MAGICNUMBER: new block starts here, this stupid workaround works until blk00976.dat where somwhere the script signature length data entry of an input is suddenly 3052914961……

    does somebody know why?

  2. mrqc renamed this:
    blk file error - did something change in the format?
    blk file error when reading - did something change in the format?
    on Nov 20, 2017
  3. jonasschnelli commented at 7:55 pm on November 20, 2017: contributor

    The blockfiles (blkXXX.dat) are not an API. Use the interface at your own risk… it may change.

    The block-files does contain the 4byte net magic, the size of the block and the serialised block data, and those three elements per block. You may need to have a closer look at transaction deserialisation to avoid an accidental offset.

  4. jonasschnelli added the label Block storage on Nov 20, 2017
  5. laanwj commented at 7:15 am on November 21, 2017: member

    In some cases there are gaps between the blocks with arbitrary junk (which sometimes looks like partical blocks). This shouldn’t be the case with newly-downloaded blockchains, but in the past there have been some bugs which resulted in this.

    Your code needs to be robust against invalid blocks when parsing the .dat files - this is why our own import logic scans over the file and considers every valid block, and if there is a parse error retries from the next possible offset; e.g. see the rewind logic in https://github.com/bitcoin/bitcoin/blob/master/src/validation.cpp#L4029 Or for a python example: https://github.com/bitcoin/bitcoin/blob/master/contrib/linearize/linearize-data.py#L199

  6. laanwj added the label Questions and Help on Nov 21, 2017
  7. jnewbery commented at 8:53 pm on March 27, 2018: member
    Suggest we close this issue.
  8. MarcoFalke closed this on Mar 27, 2018

  9. MarcoFalke locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-22 00:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me