From 401926283a200994ecd7df8eae8ced8e0b067c46 Mon Sep 17 00:00:00 2001 From: s_nakamoto Date: Wed, 25 Aug 2010 00:05:37 +0000 Subject: alert system -- version 0.3.11 git-svn-id: https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk@142 1a98c847-1fd6-4fd8-948a-caf3550aa51b --- util.cpp | 37 +++++++++++++------------------------ 1 file changed, 13 insertions(+), 24 deletions(-) (limited to 'util.cpp') diff --git a/util.cpp b/util.cpp index 2be841d07..2068e8a9e 100644 --- a/util.cpp +++ b/util.cpp @@ -14,7 +14,7 @@ char pszSetDataDir[MAX_PATH] = ""; bool fShutdown = false; bool fDaemon = false; bool fCommandLine = false; -string strWarning; +string strMiscWarning; @@ -104,12 +104,8 @@ void RandAddSeedPerfmon() RegCloseKey(HKEY_PERFORMANCE_DATA); if (ret == ERROR_SUCCESS) { - uint256 hash; - SHA256(pdata, nSize, (unsigned char*)&hash); - RAND_add(&hash, sizeof(hash), min(nSize/500.0, (double)sizeof(hash))); - hash = 0; + RAND_add(pdata, nSize, nSize/100.0); memset(pdata, 0, nSize); - printf("%s RandAddSeed() %d bytes\n", DateTimeStrFormat("%x %H:%M", GetTime()).c_str(), nSize); } #endif @@ -371,11 +367,6 @@ bool ParseMoney(const char* pszIn, int64& nRet) vector ParseHex(const char* psz) { - vector vch; - while (isspace(*psz)) - psz++; - vch.reserve((strlen(psz)+1)/3); - static char phexdigit[256] = { -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, @@ -394,24 +385,22 @@ vector ParseHex(const char* psz) -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, }; - while (*psz) + // convert hex dump to vector + vector vch; + loop { + while (isspace(*psz)) + psz++; char c = phexdigit[(unsigned char)*psz++]; if (c == -1) break; unsigned char n = (c << 4); - if (*psz) - { - char c = phexdigit[(unsigned char)*psz++]; - if (c == -1) - break; - n |= c; - vch.push_back(n); - } - while (isspace(*psz)) - psz++; + c = phexdigit[(unsigned char)*psz++]; + if (c == -1) + break; + n |= c; + vch.push_back(n); } - return vch; } @@ -761,7 +750,7 @@ void AddTimeData(unsigned int ip, int64 nTime) { fDone = true; string strMessage = _("Warning: Check your system date and time, you may not be able to generate or receive the most recent blocks!"); - strWarning = strMessage; + strMiscWarning = strMessage; printf("*** %s\n", strMessage.c_str()); boost::thread(bind(ThreadSafeMessageBox, strMessage+" ", string("Bitcoin"), wxOK | wxICON_EXCLAMATION, (wxWindow*)NULL, -1, -1)); } -- cgit v1.2.3