X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Fmain.cpp;h=cb85469af597e9411513ce10d5808439ab4f670f;hb=4f6b3161b2dc18c9a3d4143d63fbbd0737296eb0;hp=04886ed35da47165a3e8903f07dbc2265b534cfd;hpb=6776c5017b60e9ada65a00a3878b8942ddcc68de;p=novacoin.git diff --git a/src/main.cpp b/src/main.cpp index 04886ed..cb85469 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3220,7 +3220,7 @@ bool ProcessMessages(CNode* pfrom) static int64 nTimeLastPrintMessageStart = 0; if (fDebug && GetBoolArg("-printmessagestart") && nTimeLastPrintMessageStart + 30 < GetAdjustedTime()) { - string strMessageStart((const char *)pchMessageStart); + string strMessageStart((const char *)pchMessageStart, sizeof(pchMessageStart)); vector vchMessageStart(strMessageStart.begin(), strMessageStart.end()); printf("ProcessMessages : AdjustedTime=%"PRI64d" MessageStart=%s\n", GetAdjustedTime(), HexStr(vchMessageStart).c_str()); nTimeLastPrintMessageStart = GetAdjustedTime(); @@ -3598,6 +3598,7 @@ public: uint64 nLastBlockTx = 0; uint64 nLastBlockSize = 0; +int64 nLastCoinStakeSearchInterval = 0; // CreateNewBlock: // fProofOfStake: try (best effort) to make a proof-of-stake block @@ -3621,31 +3622,23 @@ CBlock* CreateNewBlock(CWallet* pwallet, bool fProofOfStake) pblock->vtx.push_back(txNew); // ppcoin: if coinstake available add coinstake tx - static unsigned int nLastCoinStakeCheckTime = GetAdjustedTime() - nMaxClockDrift / 2; // only initialized at startup + static int64 nLastCoinStakeSearchTime = GetAdjustedTime(); // only initialized at startup CBlockIndex* pindexPrev = pindexBest; if (fProofOfStake) // attemp to find a coinstake { - while (nLastCoinStakeCheckTime < GetAdjustedTime()) + pblock->nBits = GetNextTargetRequired(pindexPrev, true); + CTransaction txCoinStake; + int64 nSearchTime = GetAdjustedTime(); + if (nSearchTime > nLastCoinStakeSearchTime) { - pindexPrev = pindexBest; // get best block again to avoid getting stale - pblock->nBits = GetNextTargetRequired(pindexPrev, true); - CTransaction txCoinStake; - { - static CCriticalSection cs; - LOCK(cs); - // mining may have been suspended for a while so - // need to take max to satisfy the timestamp protocol - nLastCoinStakeCheckTime++; - nLastCoinStakeCheckTime = max(nLastCoinStakeCheckTime, (unsigned int) (GetAdjustedTime() - nMaxClockDrift / 2)); - txCoinStake.nTime = nLastCoinStakeCheckTime; - } - if (pwallet->CreateCoinStake(*pwallet, pblock->nBits, txCoinStake)) + if (pwallet->CreateCoinStake(*pwallet, pblock->nBits, nSearchTime-nLastCoinStakeSearchTime, txCoinStake)) { pblock->vtx.push_back(txCoinStake); pblock->vtx[0].vout[0].SetEmpty(); - break; } + nLastCoinStakeSearchInterval = nSearchTime - nLastCoinStakeSearchTime; + nLastCoinStakeSearchTime = nSearchTime; } } @@ -3956,9 +3949,9 @@ void BitcoinMiner(CWallet *pwallet, bool fProofOfStake) IncrementExtraNonce(pblock.get(), pindexPrev, nExtraNonce); - // ppcoin: if proof-of-stake block found then process block if (fProofOfStake) { + // ppcoin: if proof-of-stake block found then process block if (pblock->IsProofOfStake()) { if (!pblock->SignBlock(*pwalletMain))