当前位置: 首页>>代码示例>>C++>>正文


C++ CBigNum::GetHex方法代码示例

本文整理汇总了C++中CBigNum::GetHex方法的典型用法代码示例。如果您正苦于以下问题:C++ CBigNum::GetHex方法的具体用法?C++ CBigNum::GetHex怎么用?C++ CBigNum::GetHex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CBigNum的用法示例。


在下文中一共展示了CBigNum::GetHex方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GenerateMintPool

//Add the next 20 mints to the mint pool
void CzPIVWallet::GenerateMintPool(uint32_t nCountStart, uint32_t nCountEnd)
{

    //Is locked
    if (seedMaster == 0)
        return;

    uint32_t n = nCountLastUsed + 1;

    if (nCountStart > 0)
        n = nCountStart;

    uint32_t nStop = n + 20;
    if (nCountEnd > 0)
        nStop = std::max(n, n + nCountEnd);

    bool fFound;

    uint256 hashSeed = Hash(seedMaster.begin(), seedMaster.end());
    LogPrintf("%s : n=%d nStop=%d\n", __func__, n, nStop - 1);
    for (uint32_t i = n; i < nStop; ++i) {
        if (ShutdownRequested())
            return;

        fFound = false;

        // Prevent unnecessary repeated minted
        for (auto& pair : mintPool) {
            if(pair.second == i) {
                fFound = true;
                break;
            }
        }

        if(fFound)
            continue;

        uint512 seedZerocoin = GetZerocoinSeed(i);
        CBigNum bnValue;
        CBigNum bnSerial;
        CBigNum bnRandomness;
        CKey key;
        SeedToZPIV(seedZerocoin, bnValue, bnSerial, bnRandomness, key);

        mintPool.Add(bnValue, i);
        CWalletDB(strWalletFile).WriteMintPoolPair(hashSeed, GetPubCoinHash(bnValue), i);
        LogPrintf("%s : %s count=%d\n", __func__, bnValue.GetHex().substr(0, 6), i);
    }
}
开发者ID:benzmuircroft,项目名称:REWIRE.io,代码行数:50,代码来源:zpivwallet.cpp

示例2: checkProofOfWork

/// This function has changed as it served two purposes: sanity check for headers and real proof of work check. We only need the proofOfWorkLimit for the latter
/// For namecoin we allow merged mining for the PoW!
const bool NamecoinChain::checkProofOfWork(const Block& block) const {
    log_trace("Enter %s (block.version = %d)", __FUNCTION__, block.getVersion());
    // we accept aux pow all the time - the lockins will ensure we get the right chain
    // Prevent same work from being submitted twice:
    // - this block must have our chain ID
    // - parent block must not have the same chain ID (see CAuxPow::Check)
    // - index of this chain in chain merkle tree must be pre-determined (see CAuxPow::Check)
    //    if (nHeight != INT_MAX && GetChainID() != GetOurChainID())
    //    return error("CheckProofOfWork() : block does not have our chain ID");

    CBigNum target;
    target.SetCompact(block.getBits());
    if (proofOfWorkLimit() != 0 && (target <= 0 || target > proofOfWorkLimit())) {
        cout << target.GetHex() << endl;
        cout << proofOfWorkLimit().GetHex() << endl;
        log_error("CheckProofOfWork() : nBits below minimum work");
        return false;
    }
    
    if (block.getVersion()&BLOCK_VERSION_AUXPOW) {
        if (!block.getAuxPoW().Check(block.getHash(), block.getVersion()/BLOCK_VERSION_CHAIN_START)) {
            log_error("CheckProofOfWork() : AUX POW is not valid");
            return false;
        }
        // Check proof of work matches claimed amount
        if (block.getAuxPoW().GetParentBlockHash() > target.getuint256()) {
            log_error("CheckProofOfWork() : AUX proof of work failed");
            return false;
        }
    }
    else {
        // Check proof of work matches claimed amount
        if (block.getHash() > target.getuint256()) {
            log_error("CheckProofOfWork() : proof of work failed");
            return false;
        }
    }
    log_trace("Return(true): %s", __FUNCTION__);
    return true;
}
开发者ID:snowlab,项目名称:libcoin,代码行数:42,代码来源:Chain.cpp

示例3: Remove

void CMintPool::Remove(const CBigNum& bnValue)
{
    Remove(GetPubCoinHash(bnValue));
    LogPrintf("%s : remove %s from mint pool\n", __func__, bnValue.GetHex().substr(0, 6));
}
开发者ID:benzmuircroft,项目名称:REWIRE.io,代码行数:5,代码来源:mintpool.cpp

示例4: Add

void CMintPool::Add(const CBigNum& bnValue, const uint32_t& nCount)
{
    uint256 hash = GetPubCoinHash(bnValue);
    Add(make_pair(hash, nCount));
    LogPrintf("%s : add %s to mint pool, nCountLastGenerated=%d\n", __func__, bnValue.GetHex().substr(0, 6), nCountLastGenerated);
}
开发者ID:benzmuircroft,项目名称:REWIRE.io,代码行数:6,代码来源:mintpool.cpp

示例5: CreateCoinStake


//.........这里部分代码省略.........
            StakeKernelHash= CalculateStakeHashV3(CoinBlock,CoinTx,CoinTxN,txnew.nTime,GlobalCPUMiningCPID,mdPORNonce);
        }
        else
        {
            uint64_t StakeModifier = 0;
            if(!FindStakeModifierRev(StakeModifier,pindexPrev))
                continue;
            CoinWeight = CalculateStakeWeightV8(CoinTx,CoinTxN,GlobalCPUMiningCPID);
            StakeKernelHash= CalculateStakeHashV8(CoinBlock,CoinTx,CoinTxN,txnew.nTime,StakeModifier,GlobalCPUMiningCPID);
        }

        CBigNum StakeTarget;
        StakeTarget.SetCompact(blocknew.nBits);
        StakeTarget*=CoinWeight;
        StakeWeightSum += CoinWeight;
        StakeWeightMin=std::min(StakeWeightMin,CoinWeight);
        StakeWeightMax=std::max(StakeWeightMax,CoinWeight);
        double StakeKernelDiff = GetBlockDifficulty(StakeKernelHash.GetCompact())*CoinWeight;
        StakeDiffSum += StakeKernelDiff;
        StakeDiffMax = std::max(StakeDiffMax,StakeKernelDiff);

        if (fDebug2) {
            int64_t RSA_WEIGHT = GetRSAWeightByBlock(GlobalCPUMiningCPID);
            LogPrintf(
"CreateCoinStake: V%d Time %.f, Por_Nonce %.f, Bits %jd, Weight %jd\n"
" RSA_WEIGHT %.f\n"
" Stk %72s\n"
" Trg %72s\n"
" Diff %0.7f of %0.7f\n",
            blocknew.nVersion,
            (double)txnew.nTime, mdPORNonce,
            (intmax_t)blocknew.nBits,(intmax_t)CoinWeight,
            (double)RSA_WEIGHT,
            StakeKernelHash.GetHex().c_str(), StakeTarget.GetHex().c_str(),
            StakeKernelDiff, GetBlockDifficulty(blocknew.nBits)
            );
        }

        if( StakeKernelHash <= StakeTarget )
        {
            // Found a kernel
            LogPrintf("\nCreateCoinStake: Found Kernel;\n");
            blocknew.nNonce= mdPORNonce;
            vector<valtype> vSolutions;
            txnouttype whichType;
            CScript scriptPubKeyOut;
            CScript scriptPubKeyKernel;
            scriptPubKeyKernel = CoinTx.vout[CoinTxN].scriptPubKey;
            if (!Solver(scriptPubKeyKernel, whichType, vSolutions))
            {
                LogPrintf("CreateCoinStake: failed to parse kernel\n");
                break;
            }
            if (whichType == TX_PUBKEYHASH) // pay to address type
            {
                // convert to pay to public key type
                if (!wallet.GetKey(uint160(vSolutions[0]), key))
                {
                    LogPrintf("CreateCoinStake: failed to get key for kernel type=%d\n", whichType);
                    break;  // unable to find corresponding public key
                }
                scriptPubKeyOut << key.GetPubKey() << OP_CHECKSIG;
            }
            else if (whichType == TX_PUBKEY)  // pay to public key type
            {
                valtype& vchPubKey = vSolutions[0];
开发者ID:Git-Jiro,项目名称:Gridcoin-Research,代码行数:67,代码来源:miner.cpp


注:本文中的CBigNum::GetHex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。