Bitcoin Forum
July 22, 2024, 09:33:05 PM *
News: Help 1Dq create 15th anniversary forum artwork.
 
  Home Help Search Login Register More  
  Show Posts
Pages: [1]
1  Alternate cryptocurrencies / Altcoin Discussion / Re: How do I get the genesis code to work well? Please, Someone Help me~!^ on: December 05, 2021, 08:44:20 PM
When compiling the code returns:

fatal: packed object 7787377f79d120b9487bc178817913959ba05430 (stored in .git/objects/pack/pack-501f80c10a77f023a1f6e4f5da3e2992c6fc1b71.pack) is corrupt
g++ -c -O2 -pthread -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter -g -DBOOST_SPIRIT_THREADSAFE -D_FILE_OFFSET_BITS=64 -I/home/ubuntu/Desktop/eiacoin/src -I/home/ubuntu/Desktop/eiacoin/src/obj -DUSE_UPNP=0 -DUSE_IPV6=1 -I/home/ubuntu/Desktop/eiacoin/src/leveldb/include -I/home/ubuntu/Desktop/eiacoin/src/leveldb/helpers -DHAVE_BUILD_INFO -fno-stack-protector -fstack-protector-all -Wstack-protector -D_FORTIFY_SOURCE=2  -MMD -MF obj/main.d -o obj/main.o main.cpp
main.cpp: In function ‘bool InitBlockIndex()’:
main.cpp:2836:11: error: ‘genesis’ was not declared in this scope
       if (genesis.GetHash() != hashGenesisBlock) {

Solved my issue:

if (block.GetHash() != hashGenesisBlock) {
            printf("Searching for genesis block...\n");
            uint256 hashTarget = CBigNum().SetCompact(block.nBits).getuint256();

            uint256 thash;
            while (true) {
                thash = block.GetHash();
                if (thash <= hashTarget)
                    break;
                if ((block.nNonce & 0xFFF) == 0) {
                    printf("nonce %08X: hash = %s (target = %s)\n", block.nNonce, thash.ToString().c_str(), hashTarget.ToString().c_str());
                }
                ++block.nNonce;
                if (block.nNonce == 0) {
                    printf("NONCE WRAPPED, incrementing time\n");
                    ++block.nTime;
                }
            }
            printf("block.nTime = %u \n", block.nTime);
            printf("block.nNonce = %u \n", block.nNonce);
            printf("block.nVersion = %u \n", block.nVersion);
            printf("block.GetHash = %s\n", block.GetHash().ToString().c_str());

            exit(0);
        }
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!