X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Fmain.cpp;h=44f48fce904676cced2e45ecc18b7c1493897cdc;hb=67e8b40c44f9f35033a73e435021878e2f05038c;hp=334125fbe98f68d2e56c7409afe36c1fc94aceb6;hpb=44f601723c3a1c68de6e613a897e9f8418eb874a;p=novacoin.git diff --git a/src/main.cpp b/src/main.cpp index 334125f..44f48fc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -52,7 +52,7 @@ map > mapOrphanTransactionsByPrev; // Constant stuff for coinbase transactions we create: CScript COINBASE_FLAGS; -const string strMessageMagic = "Bitcoin Signed Message:\n"; +const string strMessageMagic = "PPCoin Signed Message:\n"; double dHashesPerSec; int64 nHPSTimerStart; @@ -971,8 +971,7 @@ void static InvalidChainFound(CBlockIndex* pindexNew) } printf("InvalidChainFound: invalid block=%s height=%d trust=%s\n", pindexNew->GetBlockHash().ToString().substr(0,20).c_str(), pindexNew->nHeight, CBigNum(pindexNew->nChainTrust).ToString().c_str()); printf("InvalidChainFound: current best=%s height=%d trust=%s\n", hashBestChain.ToString().substr(0,20).c_str(), nBestHeight, CBigNum(nBestChainTrust).ToString().c_str()); - if (pindexBest && nBestInvalidTrust > nBestChainTrust + pindexBest->GetBlockTrust() * 6) - printf("InvalidChainFound: WARNING: Displayed transactions may not be correct! You may need to upgrade, or other nodes may need to upgrade.\n"); + // ppcoin: should not enter safe mode for longer invalid chain } void CBlock::UpdateTime(const CBlockIndex* pindexPrev) @@ -2013,7 +2012,10 @@ bool ProcessBlock(CNode* pfrom, CBlock* pblock) // ppcoin: verify hash target and signature of coinstake tx if (pblock->IsProofOfStake() && !pblock->vtx[1].CheckProofOfStake(pblock->nBits)) - return error("ProcessBlock() : check proof-of-stake failed for block %s", hash.ToString().c_str()); + { + printf("WARNING: ProcessBlock(): check proof-of-stake failed for block %s\n", hash.ToString().c_str()); + return false; // do not error here as we expect this during initial block download + } CBlockIndex* pcheckpoint = Checkpoints::GetLastSyncCheckpoint(); if (pcheckpoint && pblock->hashPrevBlock != hashBestChain && !Checkpoints::WantedByPendingSyncCheckpoint(hash)) @@ -2094,7 +2096,7 @@ bool ProcessBlock(CNode* pfrom, CBlock* pblock) // ppcoin: if responsible for sync-checkpoint send it if (pfrom && !CSyncCheckpoint::strMasterPrivKey.empty()) - Checkpoints::SendSyncCheckpoint(hashBestChain); + Checkpoints::SendSyncCheckpoint(Checkpoints::AutoSelectSyncCheckpoint()); return true; } @@ -2163,7 +2165,7 @@ bool CheckDiskSpace(uint64 nAdditionalBytes) string strMessage = _("Warning: Disk space is low"); strMiscWarning = strMessage; printf("*** %s\n", strMessage.c_str()); - ThreadSafeMessageBox(strMessage, "Bitcoin", wxOK | wxICON_EXCLAMATION | wxMODAL); + ThreadSafeMessageBox(strMessage, "PPCoin", wxOK | wxICON_EXCLAMATION | wxMODAL); StartShutdown(); return false; } @@ -2366,7 +2368,7 @@ void PrintBlockTree() pindex->nBlockPos, block.GetHash().ToString().substr(0,20).c_str(), block.nBits, - DateTimeStrFormat("%x %H:%M:%S", block.GetBlockTime()).c_str(), + DateTimeStrFormat(block.GetBlockTime()).c_str(), block.vtx.size()); PrintWallets(block); @@ -2420,17 +2422,19 @@ string GetWarnings(string strFor) strStatusBar = strMiscWarning; } - // Longer invalid proof-of-work chain - if (pindexBest && nBestInvalidTrust > nBestChainTrust + pindexBest->GetBlockTrust() * 6) + // ppcoin: should not enter safe mode for longer invalid chain + // ppcoin: if sync-checkpoint too old enter safe mode + if (Checkpoints::IsMatureSyncCheckpoint()) { nPriority = 2000; - strStatusBar = strRPC = "WARNING: Displayed transactions may not be correct! You may need to upgrade, or other nodes may need to upgrade."; + strStatusBar = strRPC = "WARNING: Checkpoint is too old. Wait for block chain to download, or notify developers of the issue."; } + // ppcoin: if detected invalid checkpoint enter safe mode if (Checkpoints::hashInvalidCheckpoint != 0) { nPriority = 3000; - strStatusBar = strRPC = "WARNING: Invalid checkpoint found! Displayed transactions may not be correct! You may need to upgrade, or other nodes may need to upgrade."; + strStatusBar = strRPC = "WARNING: Invalid checkpoint found! Displayed transactions may not be correct! You may need to upgrade, or notify developers of the issue."; } // Alerts @@ -2443,6 +2447,8 @@ string GetWarnings(string strFor) { nPriority = alert.nPriority; strStatusBar = alert.strStatusBar; + if (nPriority > 1000) + strRPC = strStatusBar; // ppcoin: safe mode for high alert } } } @@ -2553,7 +2559,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) static map > mapReuseKey; RandAddSeedPerfmon(); if (fDebug) { - printf("%s ", DateTimeStrFormat("%x %H:%M:%S", GetTime()).c_str()); + printf("%s ", DateTimeStrFormat(GetTime()).c_str()); printf("received: %s (%d bytes)\n", strCommand.c_str(), vRecv.size()); } if (mapArgs.count("-dropmessagestest") && GetRand(atoi(mapArgs["-dropmessagestest"])) == 0) @@ -2845,8 +2851,11 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) // Bypass PushInventory, this must send even if redundant, // and we want it right after the last block so they don't // wait for other stuff first. + // ppcoin: send latest proof-of-work block to allow the + // download node to accept as orphan (proof-of-stake + // block might be rejected by stake connection check) vector vInv; - vInv.push_back(CInv(MSG_BLOCK, hashBestChain)); + vInv.push_back(CInv(MSG_BLOCK, GetLastBlockIndex(pindexBest, false)->GetBlockHash())); pfrom->PushMessage("inv", vInv); pfrom->hashContinue = 0; } @@ -3826,7 +3835,7 @@ bool CheckWork(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey) printf("BitcoinMiner:\n"); printf("new block found \n hash: %s \ntarget: %s\n", hash.GetHex().c_str(), hashTarget.GetHex().c_str()); pblock->print(); - printf("%s ", DateTimeStrFormat("%x %H:%M", GetTime()).c_str()); + printf("%s ", DateTimeStrFormat(GetTime()).c_str()); printf("generated %s\n", FormatMoney(pblock->vtx[0].vout[0].nValue).c_str()); // Found a solution @@ -3987,7 +3996,7 @@ void static BitcoinMiner(CWallet *pwallet) if (GetTime() - nLogTime > 30 * 60) { nLogTime = GetTime(); - printf("%s ", DateTimeStrFormat("%x %H:%M", GetTime()).c_str()); + printf("%s ", DateTimeStrFormat(GetTime()).c_str()); printf("hashmeter %3d CPUs %6.0f khash/s\n", vnThreadsRunning[THREAD_MINER], dHashesPerSec/1000.0); } }