while (pfork != plonger)
{
while (plonger->nHeight > pfork->nHeight)
- if (!(plonger = plonger->pprev))
+ if ((plonger = plonger->pprev) == NULL)
return error("Reorganize() : plonger->pprev is null");
if (pfork == plonger)
break;
- if (!(pfork = pfork->pprev))
+ if ((pfork = pfork->pprev) == NULL)
return error("Reorganize() : pfork->pprev is null");
}
if (mapOrphanBlocks.count(hash))
return error("ProcessBlock() : already have block (orphan) %s", hash.ToString().substr(0,20).c_str());
+ // Check that block isn't listed as unconditionally banned.
+ if (!Checkpoints::CheckBanned(hash)) {
+ if (pfrom)
+ pfrom->Misbehaving(100);
+ return error("ProcessBlock() : block %s is rejected by hard-coded banlist", hash.GetHex().substr(0,20).c_str());
+ }
+
// Check proof-of-stake
// Limited duplicity on stake: prevents block flood attack
// Duplicate stake allowed only when there is orphan child block
FILE* AppendBlockFile(unsigned int& nFileRet)
{
nFileRet = 0;
- while (true)
+ for ( ; ; )
{
FILE* file = OpenBlockFile(nCurrentBlockFile, 0, "ab");
if (!file)
unsigned char pchData[65536];
do {
fseek(blkdat, nPos, SEEK_SET);
- int nRead = fread(pchData, 1, sizeof(pchData), blkdat);
+ size_t nRead = fread(pchData, 1, sizeof(pchData), blkdat);
if (nRead <= 8)
{
nPos = std::numeric_limits<uint32_t>::max();
strRPC = "test";
// Misc warnings like out of disk space and clock is wrong
- if (strMiscWarning != "")
+ if (!strMiscWarning.empty())
{
nPriority = 1000;
strStatusBar = strMiscWarning;
}
// find last block in inv vector
- unsigned int nLastBlock = std::numeric_limits<uint32_t>::max();
- for (unsigned int nInv = 0; nInv < vInv.size(); nInv++) {
+ size_t nLastBlock = std::numeric_limits<size_t>::max();
+ for (size_t nInv = 0; nInv < vInv.size(); nInv++) {
if (vInv[vInv.size() - 1 - nInv].type == MSG_BLOCK) {
nLastBlock = vInv.size() - 1 - nInv;
break;
}
}
CTxDB txdb("r");
- for (unsigned int nInv = 0; nInv < vInv.size(); nInv++)
+ for (size_t nInv = 0; nInv < vInv.size(); nInv++)
{
const CInv &inv = vInv[nInv];
// (x) data
//
- while (true)
+ for ( ; ; )
{
// Don't bother if send buffer is too full to respond anyway
if (pfrom->vSend.size() >= SendBufferSize())