Hi guys,
I wrote a bitcoin core parser, for my personal project and because it helped me to start understanding the bitcoin protocol as a data structure.
This project mainly parsers every blk file and creates the corresponding json with the deserialized information.
I launched the alpha version of the project and actually parserizes the information and converts it into a json file, my application worked fine until the blk file number 976, where I get an exception from the blockchain library and precisely in the ReadCompactSize operation, the exception is of the type
unknown file: Failure
C++ exception with description "ReadCompactSize(): size too large: iostream error" thrown in the test body.
I use the blockchain serealize.h file to perform the decoding options because so I avoided a large part of the test for this issue and so I only created wrappers for the VarInt representation,
the code is the follow
The file .h
#include
#include "../../util/serialize.h"
using namespace std;
class DVarInt{
private:
uint64_t value;
public:
virtual ~DVarInt();
uint64_t getValue() const;
void decode(std::ifstream &stream);
};
The file cpp
#include
#include "DVarInt.h"
DVarInt::~DVarInt()
{}
uint64_t DVarInt::getValue() const
{
return value;
}
void DVarInt::decode(std::ifstream &stream)
{
value = ReadCompactSize(stream);
LOG(WARNING) << "Variant int read is: " << value;
}
What I know about this exception is that it is a bitcoin core check to avoid junk readings.
Now my question is, why does it raise this exception to file 976 and not before? Has anything changed in the representation of variable size data?
in the previously read json file that is 975 I have successfully read the last block which is the following
https://www.blockchain.com/it/btc/block/00000000000000000040d252eedd05d65326c950103d65b4f4ba1a951595b153