// print item
CBlock block;
block.ReadFromDisk(pindex);
- printf("%d (%u,%u) %s %s tx %d",
+ printf("%d (%u,%u) %s %08lx %s tx %d",
pindex->nHeight,
pindex->nFile,
pindex->nBlockPos,
block.GetHash().ToString().substr(0,20).c_str(),
+ block.nBits,
DateTimeStrFormat("%x %H:%M:%S", block.GetBlockTime()).c_str(),
block.vtx.size());
CBlock* CreateNewBlock(CWallet* pwallet)
{
- CBlockIndex* pindexPrev = pindexBest;
CReserveKey reservekey(pwallet);
// Create new block
// ppcoin: if coinstake available add coinstake tx
static unsigned int nLastCoinStakeCheckTime = GetAdjustedTime() - nMaxClockDrift; // only initialized at startup
- pblock->nBits = GetNextTargetRequired(pindexPrev, true);
+ CBlockIndex* pindexPrev = pindexBest;
while (nLastCoinStakeCheckTime < GetAdjustedTime())
{
+ pindexPrev = pindexBest; // get best block again to avoid getting stale
+ pblock->nBits = GetNextTargetRequired(pindexPrev, true);
static CCriticalSection cs;
CTransaction txCoinStake;
CRITICAL_BLOCK(cs)
break;
}
}
- if (pblock->IsProofOfWork())
- pblock->nBits = GetNextTargetRequired(pindexPrev, false);
+
+ pblock->nBits = GetNextTargetRequired(pindexPrev, pblock->IsProofOfStake());
// Collect memory pool transactions into the block
int64 nFees = 0;