4

I'm developing a parser bitcoin core and I have a problem whit the type CVarInt, I using the decodifier mode of the CCompact size but at the block 976 I Have a problem whit the type, because the value id is unusually, so I have a question why the bitcoin core decided the change implementation to CCompact size into CVarInt?

What was introduced in the bitcoin core versions to require a change of implementation?

Sorry for my terrible English but I'm learning.

1 Answer 1

3

CVarInt encoding is only used in the storage of the UTXO set internally, and never in the P2P protocol. CCompactSize is used in a number of places, including the number of transactions per block, the number of inputs and outputs per transaction, and the length of scripts.

If you're parsing block data, you will never encounter a CVarInt. If you're running into problems, it's almost certainly something else, or there is a bug in your CCompactSize decoder.

8
  • Oh this is a good news, Unfortunately I don't know exactly what block gives me problems reading the script, because for every blk file I create a json file with the list of blocks, so if I get an error reading I can't generate the json, apparte if not active the logger logs the code, which I will do soon, but for now I know that the last block that reads me converting it to json is the following This Apr 20, 2019 at 18:38
  • plus i use the library to read bitcoin core files the file is serialize.he exception that raises me is the following C ++ exception with description" ReadCompactSize (): size too large: iostream error "thrown in the test body. Apr 20, 2019 at 18:41
  • @vincenzopalazzo That probably means you're trying to decode garbage. There is no guarantee that all bytes in the block file belong to a block; there may be gaps etc Apr 20, 2019 at 19:16
  • So it is not guaranteed that all blocks have only the declared data? I mean, does this mean that in the beginning there may be other things that are not useful data for me? but in this way there must be a reference somewhere to see what is in that beginning file no? Because if bitcoin core uses that data then behind the serialization there is logic Apr 20, 2019 at 19:21
  • Blocks have well defined data only. But the files can contain garbage in addition to the blocks. There is an index database that stores which position each block is stored at. There is no guarantee that there isn't garbage between blocks (for example, for a crash while writing a block). Apr 20, 2019 at 19:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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