Changes for most chain power rule
This commit is contained in:
@@ -49,7 +49,7 @@ int64_t GetNetworkHashPS(int lookup, int height) {
|
||||
if (height >= 0 && height < chainActive.Height())
|
||||
pb = chainActive[height];
|
||||
|
||||
if (pb == NULL || !pb->nHeight)
|
||||
if (pb == NULL || !pb->GetHeight())
|
||||
return 0;
|
||||
|
||||
// If lookup is nonpositive, then use difficulty averaging window.
|
||||
@@ -57,8 +57,8 @@ int64_t GetNetworkHashPS(int lookup, int height) {
|
||||
lookup = Params().GetConsensus().nPowAveragingWindow;
|
||||
|
||||
// If lookup is larger than chain, then set it to chain length.
|
||||
if (lookup > pb->nHeight)
|
||||
lookup = pb->nHeight;
|
||||
if (lookup > pb->GetHeight())
|
||||
lookup = pb->GetHeight();
|
||||
|
||||
CBlockIndex *pb0 = pb;
|
||||
int64_t minTime = pb0->GetBlockTime();
|
||||
@@ -74,7 +74,7 @@ int64_t GetNetworkHashPS(int lookup, int height) {
|
||||
if (minTime == maxTime)
|
||||
return 0;
|
||||
|
||||
arith_uint256 workDiff = pb->nChainWork - pb0->nChainWork;
|
||||
arith_uint256 workDiff = pb->chainPower.chainWork - pb0->chainPower.chainWork;
|
||||
int64_t timeDiff = maxTime - minTime;
|
||||
|
||||
return (int64_t)(workDiff.getdouble() / timeDiff);
|
||||
@@ -273,7 +273,7 @@ UniValue generate(const UniValue& params, bool fHelp)
|
||||
}
|
||||
endloop:
|
||||
CValidationState state;
|
||||
if (!ProcessNewBlock(1,chainActive.LastTip()->nHeight+1,state, NULL, pblock, true, NULL))
|
||||
if (!ProcessNewBlock(1,chainActive.LastTip()->GetHeight()+1,state, NULL, pblock, true, NULL))
|
||||
throw JSONRPCError(RPC_INTERNAL_ERROR, "ProcessNewBlock, block not accepted");
|
||||
++nHeight;
|
||||
blockHashes.push_back(pblock->GetHash().GetHex());
|
||||
@@ -657,7 +657,7 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp)
|
||||
}
|
||||
#ifdef ENABLE_WALLET
|
||||
CReserveKey reservekey(pwalletMain);
|
||||
pblocktemplate = CreateNewBlockWithKey(reservekey,chainActive.LastTip()->nHeight+1,KOMODO_MAXGPUCOUNT);
|
||||
pblocktemplate = CreateNewBlockWithKey(reservekey,chainActive.LastTip()->GetHeight()+1,KOMODO_MAXGPUCOUNT);
|
||||
#else
|
||||
pblocktemplate = CreateNewBlockWithKey();
|
||||
#endif
|
||||
@@ -710,7 +710,7 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp)
|
||||
// Correct this if GetBlockTemplate changes the order
|
||||
// entry.push_back(Pair("foundersreward", (int64_t)tx.vout[1].nValue));
|
||||
//}
|
||||
CAmount nReward = GetBlockSubsidy(chainActive.LastTip()->nHeight+1, Params().GetConsensus());
|
||||
CAmount nReward = GetBlockSubsidy(chainActive.LastTip()->GetHeight()+1, Params().GetConsensus());
|
||||
entry.push_back(Pair("coinbasevalue", nReward));
|
||||
entry.push_back(Pair("required", true));
|
||||
txCoinbase = entry;
|
||||
@@ -748,7 +748,7 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp)
|
||||
if ( ASSETCHAINS_STAKED != 0 )
|
||||
{
|
||||
arith_uint256 POWtarget; int32_t PoSperc;
|
||||
POWtarget = komodo_PoWtarget(&PoSperc,hashTarget,(int32_t)(pindexPrev->nHeight+1),ASSETCHAINS_STAKED);
|
||||
POWtarget = komodo_PoWtarget(&PoSperc,hashTarget,(int32_t)(pindexPrev->GetHeight()+1),ASSETCHAINS_STAKED);
|
||||
result.push_back(Pair("target", POWtarget.GetHex()));
|
||||
result.push_back(Pair("PoSperc", (int64_t)PoSperc));
|
||||
result.push_back(Pair("ac_staked", (int64_t)ASSETCHAINS_STAKED));
|
||||
@@ -761,7 +761,7 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp)
|
||||
result.push_back(Pair("sizelimit", (int64_t)MAX_BLOCK_SIZE));
|
||||
result.push_back(Pair("curtime", pblock->GetBlockTime()));
|
||||
result.push_back(Pair("bits", strprintf("%08x", pblock->nBits)));
|
||||
result.push_back(Pair("height", (int64_t)(pindexPrev->nHeight+1)));
|
||||
result.push_back(Pair("height", (int64_t)(pindexPrev->GetHeight()+1)));
|
||||
|
||||
//fprintf(stderr,"return complete template\n");
|
||||
return result;
|
||||
@@ -835,7 +835,7 @@ UniValue submitblock(const UniValue& params, bool fHelp)
|
||||
CValidationState state;
|
||||
submitblock_StateCatcher sc(block.GetHash());
|
||||
RegisterValidationInterface(&sc);
|
||||
bool fAccepted = ProcessNewBlock(1,chainActive.LastTip()->nHeight+1,state, NULL, &block, true, NULL);
|
||||
bool fAccepted = ProcessNewBlock(1,chainActive.LastTip()->GetHeight()+1,state, NULL, &block, true, NULL);
|
||||
UnregisterValidationInterface(&sc);
|
||||
if (fBlockPresent)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user