挖掘比特币硬币时条件错误?

时间:2015-02-05 09:01:33

标签: c++ linux hash cryptography bitcoin

当我在main.cpp中使用BitcoinMiner()中的Premine-Coin源代码尝试挖掘硬币时,我的一个条件总是错误的,我不知道是什么问题,因为它使用了Premine-coin(原始代码),当我改变我的创世纪,nNonce,nTime和所有它总是假的条件。请参阅下面提到的代码,其中if(hash< = hashTarget)总是变为false。我如何解决这个问题。

int64 nStart = GetTime();
uint256 hashTarget = CBigNum().SetCompact(pblock->nBits).getuint256();
uint256 hashbuf[2];
uint256& hash = *alignup<16>(hashbuf);

        loop
        {
            unsigned int nHashesDone = 0;
            unsigned int nNonceFound;
            // Crypto++ SHA256
            nNonceFound = ScanHash_CryptoPP(pmidstate, pdata + 64, phash1,                                         (char*)&hash, nHashesDone);

            // Check if something found
            if (nNonceFound != (unsigned int) -1)
            {
                for (unsigned int i = 0; i < sizeof(hash)/2; i++)
                {
                    ((unsigned int*)&hash)[i] = ByteReverse(((unsigned int*)&hash)[i]);
                }
                if (hash <= hashTarget)  // Problem is here: hash is always greater than hashTarget
                {
                    // Found a solution
                    pblock->nNonce = ByteReverse(nNonceFound);
                    assert(hash == pblock->GetHash());
                    SetThreadPriority(THREAD_PRIORITY_NORMAL);
                    CheckWork(pblock, *pwalletMain, reservekey);
                    SetThreadPriority(THREAD_PRIORITY_LOWEST);
                    break;
                }
            }

0 个答案:

没有答案