X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Frpcmining.cpp;h=5d796faa32ca9e0b1f72c6b82b2cabba57646f3c;hb=7e9ceb798f2685429f3387625beb872bbda1567c;hp=e6219861e15afca7d641355752a1f73f5f710100;hpb=adb8391acdf671640adb1e8be564e68b254fca69;p=novacoin.git diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index e621986..5d796fa 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -20,54 +20,14 @@ Value getmininginfo(const Array& params, bool fHelp) "getmininginfo\n" "Returns an object containing mining-related information."); - double dStakeKernelsTriedAvg = 0; - int nPoWInterval = 72, nPoSInterval = 72, nStakesHandled = 0, nStakesTime = 0; - int64 nTargetSpacingWorkMin = 30, nTargetSpacingWork = 30; - - 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("blockvalue", (uint64_t)GetProofOfWorkReward(GetLastBlockIndex(pindexBest, false)->nBits))); - obj.push_back(Pair("netmhashps", dNetworkMhps)); - obj.push_back(Pair("netstakeweight", dNetworkWeight)); + obj.push_back(Pair("netmhashps", GetPoWMHashPS())); + obj.push_back(Pair("netstakeweight", GetPoSKernelPS())); obj.push_back(Pair("errors", GetWarnings("statusbar"))); obj.push_back(Pair("pooledtx", (uint64_t)mempool.size())); obj.push_back(Pair("stakeweight", (uint64_t)pwalletMain->GetStakeWeight(*pwalletMain, STAKE_NORMAL))); @@ -200,12 +160,6 @@ Value getworkex(const Array& params, bool fHelp) pblock->hashMerkleRoot = pblock->BuildMerkleTree(); - if (!fTestNet && pblock->GetBlockTime() < CHAINCHECKS_SWITCH_TIME) - { - if (!pblock->SignBlock(*pwalletMain)) - throw JSONRPCError(-100, "Unable to sign block, wallet locked?"); - } - return CheckWork(pblock, *pwalletMain, reservekey); } } @@ -319,12 +273,6 @@ Value getwork(const Array& params, bool fHelp) pblock->vtx[0].vin[0].scriptSig = mapNewBlock[pdata->hashMerkleRoot].second; pblock->hashMerkleRoot = pblock->BuildMerkleTree(); - if (!fTestNet && pblock->GetBlockTime() < CHAINCHECKS_SWITCH_TIME) - { - if (!pblock->SignBlock(*pwalletMain)) - throw JSONRPCError(-100, "Unable to sign block, wallet locked?"); - } - return CheckWork(pblock, *pwalletMain, reservekey); } } @@ -506,12 +454,6 @@ Value submitblock(const Array& params, bool fHelp) throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "Block decode failed"); } - if (!fTestNet && block.GetBlockTime() < CHAINCHECKS_SWITCH_TIME) - { - if (!block.SignBlock(*pwalletMain)) - throw JSONRPCError(-100, "Unable to sign block, wallet locked?"); - } - bool fAccepted = ProcessBlock(NULL, &block); if (!fAccepted) return "rejected";