}
if (fDebug)
- printf("Get stake weight: %zu meta items loaded for %zu coins\n", mapMeta.size(), setCoins.size());
+ printf("Get stake weight: %d meta items loaded for %d coins\n", mapMeta.size(), setCoins.size());
fCoinsDataActual = true;
}
}
if (fDebug)
- printf("Stake miner: %zu meta items loaded for %zu coins\n", mapMeta.size(), setCoins.size());
+ printf("Stake miner: %d meta items loaded for %d coins\n", mapMeta.size(), setCoins.size());
fCoinsDataActual = true;
}
CTxDB txdb("r");
if (!txNew.GetCoinAge(txdb, nCoinAge))
return error("CreateCoinStake : failed to calculate coin age");
- nCredit += GetProofOfStakeReward(nCoinAge, nBits, txNew.nTime);
+
+ int64 nReward = GetProofOfStakeReward(nCoinAge, nBits, txNew.nTime);
+ // Refuse to create mint that has zero or negative reward
+ if(nReward <= 0)
+ return false;
+
+ nCredit += nReward;
}
int64 nMinFee = 0;
for (std::map<CKeyID, CBlockIndex*>::const_iterator it = mapKeyFirstBlock.begin(); it != mapKeyFirstBlock.end(); it++)
mapKeyBirth[it->first] = it->second->nTime - 7200; // block times can be 2h off
}
+
+void CWallet::ClearOrphans()
+{
+ list<uint256> orphans;
+
+ LOCK(cs_wallet);
+ for(map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it)
+ {
+ const CWalletTx *wtx = &(*it).second;
+ if((wtx->IsCoinBase() || wtx->IsCoinStake()) && !wtx->IsInMainChain())
+ {
+ orphans.push_back(wtx->GetHash());
+ }
+ }
+
+ for(list<uint256>::const_iterator it = orphans.begin(); it != orphans.end(); ++it)
+ EraseFromWallet(*it);
+}