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


C++ CBlockIndex::IsProofOfWork方法代码示例

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


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

示例1: GetPoWMHashPS

double GetPoWMHashPS(const CBlockIndex* blockindex)
{
    int nPoWInterval = 72;
    int64 nTargetSpacingWorkMin = 1, nTargetSpacingWork = 1;

    CBlockIndex* pindex = pindexGenesisBlock;
    CBlockIndex* pindexPrevWork = pindexGenesisBlock;
    const CBlockIndex* pindexStop = pindexBest;

    if (blockindex != NULL)
        pindexStop = blockindex;

    while (pindex && pindex->nHeight < pindexStop->nHeight)
    {
        if (pindex->IsProofOfWork())
        {
            int64 nActualSpacingWork = pindex->GetBlockTime() - pindexPrevWork->GetBlockTime();
            nTargetSpacingWork = ((nPoWInterval - 1) * nTargetSpacingWork + nActualSpacingWork + nActualSpacingWork) / (nPoWInterval + 1);
            nTargetSpacingWork = max(nTargetSpacingWork, nTargetSpacingWorkMin);
            pindexPrevWork = pindex;
        }

        pindex = pindex->pnext;
    }

    return GetDifficulty(pindexPrevWork) * 4294967.296 / nTargetSpacingWork;
}
开发者ID:scificrypto,项目名称:Gold-Pressed-Latinum,代码行数:27,代码来源:rpcblockchain.cpp

示例2: GetPoWMHashPS

double GetPoWMHashPS()
{
    if (pindexBest->nHeight >= LAST_POW_BLOCK)
        return 0;

    int nPoWInterval = 72;
    int64_t nTargetSpacingWorkMin = 30, nTargetSpacingWork = 30;

    CBlockIndex* pindex = pindexGenesisBlock;
    CBlockIndex* pindexPrevWork = pindexGenesisBlock;

    while (pindex)
    {
        if (pindex->IsProofOfWork())
        {
            int64_t nActualSpacingWork = pindex->GetBlockTime() - pindexPrevWork->GetBlockTime();
            nTargetSpacingWork = ((nPoWInterval - 1) * nTargetSpacingWork + nActualSpacingWork + nActualSpacingWork) / (nPoWInterval + 1);
            nTargetSpacingWork = max(nTargetSpacingWork, nTargetSpacingWorkMin);
            pindexPrevWork = pindex;
        }

        pindex = pindex->pnext;
    }

    return GetDifficulty() * 4294.967296 / nTargetSpacingWork;
}
开发者ID:redconan,项目名称:martexcoin,代码行数:26,代码来源:rpcblockchain.cpp

示例3: GetPoWMHashPS

double GetPoWMHashPS()
{
    //This was done to fix the early end POW for goodcoin.
   // if (pindexBest->nHeight >= LAST_POW_BLOCK)
   //     return 0;
    if ((pindexBest->nHeight >= LAST_POW_BLOCK && pindexBest->nHeight < JUMP_TO_POW_BLOCK) || (pindexBest->nHeight >= REAL_LAST_POW_BLOCK))
        return 0;

    int nPoWInterval = 72;
    int64 nTargetSpacingWorkMin = 30, nTargetSpacingWork = 30;

    CBlockIndex* pindex = pindexGenesisBlock;
    CBlockIndex* pindexPrevWork = pindexGenesisBlock;

    while (pindex)
    {
        if (pindex->IsProofOfWork())
        {
            int64 nActualSpacingWork = pindex->GetBlockTime() - pindexPrevWork->GetBlockTime();
            nTargetSpacingWork = ((nPoWInterval - 1) * nTargetSpacingWork + nActualSpacingWork + nActualSpacingWork) / (nPoWInterval + 1);
            nTargetSpacingWork = max(nTargetSpacingWork, nTargetSpacingWorkMin);
            pindexPrevWork = pindex;
        }

        pindex = pindex->pnext;
    }

    return GetDifficulty() * 4294.967296 / nTargetSpacingWork;
}
开发者ID:flu663r,项目名称:gcfinal,代码行数:29,代码来源:rpcblockchain.cpp

示例4: getmininginfo

Value getmininginfo(const Array& params, bool fHelp)
{
    if (fHelp || params.size() != 0)
        throw runtime_error(
            "getmininginfo\n"
            "Returns an object containing mining-related information.");

    int64 nTargetSpacingWorkMin = 2;
    int64 nTargetSpacingWork = nTargetSpacingWorkMin;
    int64 nPoWInterval = 15;
    int64 nTargetSpacingStake = 120;

    CBlockIndex* pindex = pindexGenesisBlock;
    CBlockIndex* pindexPrevWork = pindexGenesisBlock;

    while (pindex)
    {
        if (pindex->IsProofOfWork())
        {
            int64 nActualSpacingWork = pindex->GetBlockTime() - pindexPrevWork->GetBlockTime();
            nTargetSpacingWork = ((nPoWInterval - 1) * nTargetSpacingWork + nActualSpacingWork + nActualSpacingWork) / (nPoWInterval + 1);
            nTargetSpacingWork = max(nTargetSpacingWork, nTargetSpacingWorkMin);
            pindexPrevWork = pindex;
        }

        pindex = pindex->pnext;
    }
    
    double dNetworkMhps = GetDifficulty() * 4294.967296 / nTargetSpacingWork;
    int nNetworkWeight = GetDifficulty(GetLastBlockIndex(pindexBest, true)) * 4294967296 / nTargetSpacingStake;
   
    Object obj;
    obj.push_back(Pair("blocks", (int)nBestHeight));
    obj.push_back(Pair("currentblocksize",(uint64_t)nLastBlockSize));
    obj.push_back(Pair("currentblocktx",(uint64_t)nLastBlockTx));
    obj.push_back(Pair("difficulty", (double)GetDifficulty()));
    obj.push_back(Pair("networkhashps", getnetworkhashps(params, false)));
    obj.push_back(Pair("PoWmhashps", dNetworkMhps));
    obj.push_back(Pair("netstake", (uint64_t) nNetworkWeight));
    obj.push_back(Pair("errors", GetWarnings("statusbar")));
    obj.push_back(Pair("pooledtx", (uint64_t)mempool.size()));
    obj.push_back(Pair("BelowWeight", (uint64_t)pwalletMain->GetStakeMintPower(*pwalletMain, STAKE_BELOWMIN)));
    obj.push_back(Pair("MinWeight", (uint64_t)pwalletMain->GetStakeMintPower(*pwalletMain, STAKE_MINWEIGHT)));
    obj.push_back(Pair("MaxWeight", (uint64_t)pwalletMain->GetStakeMintPower(*pwalletMain, STAKE_MAXWEIGHT)));
    obj.push_back(Pair("TotalWeight", (uint64_t)pwalletMain->GetStakeMintPower(*pwalletMain, STAKE_NORMAL)));
    obj.push_back(Pair("StakeReadyStones", ((uint64_t)pwalletMain->GetStakeMintPower(*pwalletMain, STAKE_NORMAL))/730));
    obj.push_back(Pair("stakeinterest", (uint64_t)GetProofOfStakeReward(0, GetLastBlockIndex(pindexBest, true)->nBits, GetLastBlockIndex(pindexBest, true)->nTime)));
    obj.push_back(Pair("testnet", fTestNet));
    return obj;
}
开发者ID:kyonetca,项目名称:philosopherstone,代码行数:50,代码来源:rpcmining.cpp

示例5: getmininginfo

Value getmininginfo(CWallet* pWallet, const Array& params, bool fHelp)
{
    if (fHelp || params.size() != 0)
        throw runtime_error(
            "getmininginfo\n"
            "Returns an object containing mining-related information.");

    int64 nTargetSpacingWorkMin = 30;
    int64 nTargetSpacingWork = nTargetSpacingWorkMin;
    int64 nPoWInterval = 72;
    int64 nTargetSpacingStake = 600;

    CBlockIndex* pindex = pindexGenesisBlock;
    CBlockIndex* pindexPrevWork = pindexGenesisBlock;

    while (pindex)
    {
        if (pindex->IsProofOfWork())
        {
            int64 nActualSpacingWork = pindex->GetBlockTime() - pindexPrevWork->GetBlockTime();
            nTargetSpacingWork = ((nPoWInterval - 1) * nTargetSpacingWork + nActualSpacingWork + nActualSpacingWork) / (nPoWInterval + 1);
            nTargetSpacingWork = max(nTargetSpacingWork, nTargetSpacingWorkMin);
            pindexPrevWork = pindex;
        }

        pindex = pindex->pnext;
    }

    double dNetworkMhps = GetDifficulty() * 4294.967296 / nTargetSpacingWork;
    int nNetworkWeight = GetDifficulty(GetLastBlockIndex(pindexBest, true)) * 4294967296 / nTargetSpacingStake;

    Object obj;
    obj.push_back(Pair("blocks",        (int)nBestHeight));
    obj.push_back(Pair("currentblocksize",(uint64_t)nLastBlockSize));
    obj.push_back(Pair("currentblocktx",(uint64_t)nLastBlockTx));
    obj.push_back(Pair("difficulty",    (double)GetDifficulty()));
    obj.push_back(Pair("errors",        GetWarnings("statusbar")));
    obj.push_back(Pair("netmhashps",     dNetworkMhps));
    obj.push_back(Pair("netstakeweight", nNetworkWeight));
    obj.push_back(Pair("generate",      GetBoolArg("-gen")));
    obj.push_back(Pair("genproclimit",  (int)GetArg("-genproclimit", -1)));
    obj.push_back(Pair("hashespersec",  gethashespersec(NULL, params, false)));
    obj.push_back(Pair("stakeweight",   (uint64_t)pWallet->GetStakeMintPower(*pWallet)));
    obj.push_back(Pair("stakeinterest", (uint64_t)GetProofOfStakeReward(0, GetLastBlockIndex(pindexBest, true)->nBits, GetTime())));
    obj.push_back(Pair("pooledtx",      (uint64_t)mempool.size()));
    obj.push_back(Pair("testnet",       fTestNet));
    return obj;
}
开发者ID:CCPorg,项目名称:HBN-HoboNickels-Ver-1.2.1.5-Copy,代码行数:48,代码来源:rpcmining.cpp

示例6: GetPoWMHashPS

double GetPoWMHashPS()
{
    if (GetBoolArg("-testnet")){
        if (pindexBest->nHeight >= P1_End_TestNet && pindexBest->nHeight < P2_Start_TestNet){
            return 0;
        } else if (pindexBest->nHeight > P2_End_TestNet){
            return 0;
        }
    }else {
        if (pindexBest->nHeight >= P1_End && pindexBest->nHeight < P2_Start){
            return 0;
        } else if (pindexBest->nHeight > P2_End){
            return 0;
        }
    }


    int nPoWInterval = 72;
    int64_t nTargetSpacingWorkMin = 30, nTargetSpacingWork = 30;

    CBlockIndex* pindex = pindexGenesisBlock;
    CBlockIndex* pindexPrevWork = pindexGenesisBlock;

    while (pindex)
    {
        if (pindex->IsProofOfWork())
        {
            int64_t nActualSpacingWork = pindex->GetBlockTime() - pindexPrevWork->GetBlockTime();
            nTargetSpacingWork = ((nPoWInterval - 1) * nTargetSpacingWork + nActualSpacingWork + nActualSpacingWork) / (nPoWInterval + 1);
            nTargetSpacingWork = max(nTargetSpacingWork, nTargetSpacingWorkMin);
            pindexPrevWork = pindex;
        }

        pindex = pindex->pnext;
    }

    return GetDifficulty() * 4294.967296 / nTargetSpacingWork;
}
开发者ID:BitAltcoin,项目名称:bitaltcoinx,代码行数:38,代码来源:rpcblockchain.cpp

示例7: getmininginfo

Value getmininginfo(const Array& params, bool fHelp)
{
    if (fHelp || params.size() != 0)
        throw runtime_error(
            "getmininginfo\n"
            "Returns an object containing mining-related information.");

    double dStakeKernelsTriedAvg = 0;
    int nPoWInterval = 72, nPoSInterval = 72, nStakesHandled = 0, nStakesTime = 0;
    int64 nTargetSpacingWorkMin = 2, nTargetSpacingWork = 2;

    CBlockIndex* pindex = pindexGenesisBlock;
    CBlockIndex* pindexPrevWork = pindexGenesisBlock;
    CBlockIndex* pindexPrevStake = NULL;

    while (pindex)
    {
        if (pindex->IsProofOfWork())
        {
            int64 nActualSpacingWork = pindex->GetBlockTime() - pindexPrevWork->GetBlockTime();
            nTargetSpacingWork = ((nPoWInterval - 1) * nTargetSpacingWork + nActualSpacingWork + nActualSpacingWork) / (nPoWInterval + 1);
            nTargetSpacingWork = max(nTargetSpacingWork, nTargetSpacingWorkMin);
            pindexPrevWork = pindex;
        }

        pindex = pindex->pnext;
    }


    pindex = pindexBest;

    while (pindex && nStakesHandled < nPoSInterval)
    {
        if (pindex->IsProofOfStake())
        {
            dStakeKernelsTriedAvg += GetDifficulty(pindex) * 4294967296;
            nStakesTime += pindexPrevStake ? (pindexPrevStake->nTime - pindex->nTime) : 0;
            pindexPrevStake = pindex;
            nStakesHandled++;
        }

        pindex = pindex->pprev;
    }

    double dNetworkMhps = GetDifficulty() * 4294.967296 / nTargetSpacingWork;
    double dNetworkWeight = dStakeKernelsTriedAvg / nStakesTime;

    Object obj;
    obj.push_back(Pair("blocks", (int)nBestHeight));
    obj.push_back(Pair("currentblocksize",(uint64_t)nLastBlockSize));
    obj.push_back(Pair("currentblocktx",(uint64_t)nLastBlockTx));
    obj.push_back(Pair("difficulty", (double)GetDifficulty()));
    obj.push_back(Pair("networkhashps", getnetworkhashps(params, false)));
    //obj.push_back(Pair("blockvalue", (uint64_t)GetProofOfWorkReward(GetLastBlockIndex(pindexBest, false)->nBits)));
    //obj.push_back(Pair("powmhashps", dNetworkMhps));
    obj.push_back(Pair("netstakeweight", dNetworkWeight));
    obj.push_back(Pair("errors", GetWarnings("statusbar")));
    obj.push_back(Pair("pooledtx", (uint64_t)mempool.size()));
    obj.push_back(Pair("belowweight", (uint64_t)pwalletMain->GetStakeWeight(*pwalletMain, STAKE_BELOWMIN)));
    obj.push_back(Pair("stakeweight", (uint64_t)pwalletMain->GetStakeWeight(*pwalletMain, STAKE_NORMAL)));
    obj.push_back(Pair("minweight", (uint64_t)pwalletMain->GetStakeWeight(*pwalletMain, STAKE_MINWEIGHT)));
    obj.push_back(Pair("maxweight", (uint64_t)pwalletMain->GetStakeWeight(*pwalletMain, STAKE_MAXWEIGHT)));
    obj.push_back(Pair("StakeReadytunes", ((uint64_t)pwalletMain->GetStakeWeight(*pwalletMain, STAKE_NORMAL))/730));
    //obj.push_back(Pair("stakeinterest", (uint64_t)GetProofOfStakeReward(0, GetLastBlockIndex(pindexBest, true)->nBits, GetLastBlockIndex(pindexBest, true)->nTime, true)));
    obj.push_back(Pair("testnet", fTestNet));
    return obj;
}
开发者ID:classicsxdx,项目名称:zz,代码行数:67,代码来源:rpcmining.cpp


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