Bitcoin Forum
May 04, 2024, 01:48:21 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
  Home Help Search Login Register More  
  Show Posts
Pages: [1]
1  Bitcoin / Development & Technical Discussion / Re: Exception CompactSize when I parsering a nuimbar od the blk file >= 976 on: April 22, 2019, 02:14:24 PM
Hi,

It may be the end of the file ? You should also note that there is not a blk file per block. Here is a resource that might help you with parsing blks : https://learnmeabitcoin.com/glossary/blkdat.

Thanks for your reply, to be honest the error gives it to me at the beginning of the file.
Each blk file contains a series of blocks up to a maximum of 128 megabytes, even if the files are actually a bit larger, 130/133 megabytes right?

But one thing I know is that a block is entirely contained in a blk file and does not continue in another file right?

Thanks for the reference and 'a post that I have already seen
Did you host the code somewhere ? If yes could you point me to it ?

I have the code on github because it's not ready yet but now I make it public, the code is written in C ++ where I'm new, so forgive my C ++ errors but I'm refactoring

https://github.com/vincenzopalazzo/SpyCblock
2  Bitcoin / Development & Technical Discussion / Re: Exception CompactSize when I parsering a nuimbar od the blk file >= 976 on: April 22, 2019, 02:01:16 PM
Hi,

It may be the end of the file ? You should also note that there is not a blk file per block. Here is a resource that might help you with parsing blks : https://learnmeabitcoin.com/glossary/blkdat.

Thanks for your reply, to be honest the error gives it to me at the beginning of the file.
Each blk file contains a series of blocks up to a maximum of 128 megabytes, even if the files are actually a bit larger, 130/133 megabytes right?

But one thing I know is that a block is entirely contained in a blk file and does not continue in another file right?

Thanks for the reference and 'a post that I have already seen
3  Bitcoin / Development & Technical Discussion / Exception CompactSize when I parsering a nuimbar od the blk file >= 976 on: April 22, 2019, 01:37:26 PM
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

Code:
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
Code:
#include <fstream>

#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

Code:
#include <glog/logging.h>

#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
Pages: [1]
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!