Author

Topic: Trying to rebase altcoin to latest BTC, ReadCompactSize of headers too large (Read 623 times)

hero member
Activity: 690
Merit: 501
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 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.
Jump to: