Bitcoin Forum
June 30, 2024, 02:33:06 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Trying to rebase altcoin to latest BTC, ReadCompactSize of headers too large  (Read 623 times)
cloudboy (OP)
Hero Member
*****
Offline Offline

Activity: 690
Merit: 501


View Profile
March 11, 2015, 04:01:18 PM
 #1

Hi,

I am trying to rebase an old codebase to the latest BTC (.10) with headers first sync.

I am getting the correct block hashes in order from peers, but when it calls ReadCompactSize() it throws 'size too large' error.

Code:
    else if (strCommand == "headers" && !fImporting && !fReindex) // Ignore headers received while importing
    {
        std::vector<CBlockHeader> headers;
        // Bypass the normal CBlock deserialization, as we don't want to risk deserializing 2000 full blocks.
        unsigned int nCount = ReadCompactSize(vRecv);
        if (nCount > MAX_HEADERS_RESULTS) {
            Misbehaving(pfrom->GetId(), 20);
            return error("headers message size = %u", nCount);
        }

        headers.resize(nCount);
        for (unsigned int n = 0; n < nCount; n++) {
            vRecv >> headers[n];
            ReadCompactSize(vRecv); // ignore tx count; assume it is 0.
        }

If I comment out
Code:
    if (nSizeRet > (uint64_t)MAX_SIZE)
        throw std::ios_base::failure("ReadCompactSize(): size too large");
in serialize.h, then it works somewhat. The genesis block at headers[0] is correct, but every subsequent block hash is shifted 4 bytes to the left.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!