// print item
CBlock block;
block.ReadFromDisk(pindex);
- printf("%d (%u,%u) %s %08lx %s mint %s tx %d",
+ printf("%d (%u,%u) %s %08lx %s mint %7s tx %d",
pindex->nHeight,
pindex->nFile,
pindex->nBlockPos,
- block.GetHash().ToString().substr(0,20).c_str(),
+ block.GetHash().ToString().c_str(),
block.nBits,
DateTimeStrFormat(block.GetBlockTime()).c_str(),
FormatMoney(pindex->nMint).c_str(),
static int64 nTimeLastPrintMessageStart = 0;
if (fDebug && GetBoolArg("-printmessagestart") && nTimeLastPrintMessageStart + 30 < GetAdjustedTime())
{
- string strMessageStart((const char *)pchMessageStart);
+ string strMessageStart((const char *)pchMessageStart, sizeof(pchMessageStart));
vector<unsigned char> vchMessageStart(strMessageStart.begin(), strMessageStart.end());
printf("ProcessMessages : AdjustedTime=%"PRI64d" MessageStart=%s\n", GetAdjustedTime(), HexStr(vchMessageStart).c_str());
nTimeLastPrintMessageStart = GetAdjustedTime();
uint64 nLastBlockTx = 0;
uint64 nLastBlockSize = 0;
+int64 nLastCoinStakeSearchInterval = 0;
// CreateNewBlock:
// fProofOfStake: try (best effort) to make a proof-of-stake block
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;
}
}
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))