From 58561410692c520d91def67c36aadf8edd992272 Mon Sep 17 00:00:00 2001 From: Sunny King Date: Wed, 25 Jul 2012 23:57:31 +0100 Subject: [PATCH] PPCoin: Change date display format and clean up a merge issue --- src/bitcoinrpc.cpp | 2 +- src/main.cpp | 12 ++++++------ src/net.cpp | 6 +++--- src/net.h | 2 +- src/rpcdump.cpp | 9 +++++---- src/util.cpp | 17 ++++++++--------- src/util.h | 6 ++++++ src/wallet.cpp | 13 ++++++++----- src/walletdb.cpp | 5 +++-- 9 files changed, 41 insertions(+), 31 deletions(-) diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp index c0c9d2d..04faea9 100644 --- a/src/bitcoinrpc.cpp +++ b/src/bitcoinrpc.cpp @@ -2023,7 +2023,7 @@ Value getcheckpoint(const Array& params, bool fHelp) result.push_back(Pair("synccheckpoint", Checkpoints::hashSyncCheckpoint.ToString().c_str())); pindexCheckpoint = mapBlockIndex[Checkpoints::hashSyncCheckpoint]; result.push_back(Pair("height", pindexCheckpoint->nHeight)); - result.push_back(Pair("timestamp", DateTimeStrFormat("%x %H:%M:%S", pindexCheckpoint->GetBlockTime()).c_str())); + result.push_back(Pair("timestamp", DateTimeStrFormat(pindexCheckpoint->GetBlockTime()).c_str())); return result; } diff --git a/src/main.cpp b/src/main.cpp index 334125f..70d6744 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; @@ -2163,7 +2163,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 +2366,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); @@ -2553,7 +2553,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) @@ -3826,7 +3826,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 +3987,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); } } diff --git a/src/net.cpp b/src/net.cpp index 5d5be71..a650979 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -383,7 +383,7 @@ void CNode::CloseSocketDisconnect() if (hSocket != INVALID_SOCKET) { if (fDebug) - printf("%s ", DateTimeStrFormat("%x %H:%M:%S", GetTime()).c_str()); + printf("%s ", DateTimeStrFormat(GetTime()).c_str()); printf("disconnecting node %s\n", addr.ToString().c_str()); closesocket(hSocket); hSocket = INVALID_SOCKET; @@ -888,7 +888,7 @@ void ThreadMapPort2(void* parg) } } - string strDesc = "Bitcoin " + FormatFullVersion(); + string strDesc = "PPCoin " + FormatFullVersion(); #ifndef UPNPDISCOVER_SUCCESS /* miniupnpc 1.5 */ r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype, @@ -1478,7 +1478,7 @@ bool BindListenPort(string& strError) { int nErr = WSAGetLastError(); if (nErr == WSAEADDRINUSE) - strError = strprintf(_("Unable to bind to port %d on this computer. Bitcoin is probably already running."), ntohs(sockaddr.sin_port)); + strError = strprintf(_("Unable to bind to port %d on this computer. PPCoin is probably already running."), ntohs(sockaddr.sin_port)); else strError = strprintf("Error: Unable to bind to port %d on this computer (bind returned error %d)", ntohs(sockaddr.sin_port), nErr); printf("%s\n", strError.c_str()); diff --git a/src/net.h b/src/net.h index c0cda53..4178675 100644 --- a/src/net.h +++ b/src/net.h @@ -294,7 +294,7 @@ public: vSend << CMessageHeader(pszCommand, 0); nMessageStart = vSend.size(); if (fDebug) { - printf("%s ", DateTimeStrFormat("%x %H:%M:%S", GetTime()).c_str()); + printf("%s ", DateTimeStrFormat(GetTime()).c_str()); printf("sending: %s ", pszCommand); } } diff --git a/src/rpcdump.cpp b/src/rpcdump.cpp index 2db4882..bf22efd 100644 --- a/src/rpcdump.cpp +++ b/src/rpcdump.cpp @@ -1,4 +1,5 @@ // Copyright (c) 2009-2012 Bitcoin Developers +// Copyright (c) 2012 The PPCoin developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -42,7 +43,7 @@ Value importprivkey(const Array& params, bool fHelp) { if (fHelp || params.size() < 1 || params.size() > 2) throw runtime_error( - "importprivkey [label]\n" + "importprivkey [label]\n" "Adds a private key (as returned by dumpprivkey) to your wallet."); string strSecret = params[0].get_str(); @@ -82,13 +83,13 @@ Value dumpprivkey(const Array& params, bool fHelp) { if (fHelp || params.size() != 1) throw runtime_error( - "dumpprivkey \n" - "Reveals the private key corresponding to ."); + "dumpprivkey \n" + "Reveals the private key corresponding to ."); string strAddress = params[0].get_str(); CBitcoinAddress address; if (!address.SetString(strAddress)) - throw JSONRPCError(-5, "Invalid bitcoin address"); + throw JSONRPCError(-5, "Invalid ppcoin address"); CSecret vchSecret; bool fCompressed; if (!pwalletMain->GetSecret(address, vchSecret, fCompressed)) diff --git a/src/util.cpp b/src/util.cpp index 89509b1..4e259e4 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -155,7 +155,7 @@ void RandAddSeedPerfmon() { 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); + printf("%s RandAddSeed() %d bytes\n", DateTimeStrFormat(GetTime()).c_str(), nSize); } #endif } @@ -224,7 +224,7 @@ inline int OutputDebugStringF(const char* pszFormat, ...) // Debug print useful for profiling if (fLogTimestamps && fStartedNewLine) - fprintf(fileout, "%s ", DateTimeStrFormat("%x %H:%M:%S", GetTime()).c_str()); + fprintf(fileout, "%s ", DateTimeStrFormat(GetTime()).c_str()); if (pszFormat[strlen(pszFormat) - 1] == '\n') fStartedNewLine = true; else @@ -777,7 +777,7 @@ void FormatException(char* pszMessage, std::exception* pex, const char* pszThrea pszModule[0] = '\0'; GetModuleFileNameA(NULL, pszModule, sizeof(pszModule)); #else - const char* pszModule = "bitcoin"; + const char* pszModule = "ppcoin"; #endif if (pex) snprintf(pszMessage, 1000, @@ -1071,10 +1071,10 @@ void AddTimeData(const CNetAddr& ip, int64 nTime) if (!fMatch) { fDone = true; - string strMessage = _("Warning: Please check that your computer's date and time are correct. If your clock is wrong Bitcoin will not work properly."); + string strMessage = _("Warning: Please check that your computer's date and time are correct. If your clock is wrong PPCoin will not work properly."); strMiscWarning = strMessage; printf("*** %s\n", strMessage.c_str()); - ThreadSafeMessageBox(strMessage+" ", string("Bitcoin"), wxOK | wxICON_EXCLAMATION); + ThreadSafeMessageBox(strMessage+" ", string("PPCoin"), wxOK | wxICON_EXCLAMATION); } } } @@ -1122,7 +1122,7 @@ std::string FormatSubVersion(const std::string& name, int nClientVersion, const #ifdef WIN32 boost::filesystem::path static StartupShortcutPath() { - return MyGetSpecialFolderPath(CSIDL_STARTUP, true) / "Bitcoin.lnk"; + return MyGetSpecialFolderPath(CSIDL_STARTUP, true) / "PPCoin.lnk"; } bool GetStartOnSystemStartup() @@ -1203,7 +1203,7 @@ boost::filesystem::path static GetAutostartDir() boost::filesystem::path static GetAutostartFilePath() { - return GetAutostartDir() / "bitcoin.desktop"; + return GetAutostartDir() / "ppcoin.desktop"; } bool GetStartOnSystemStartup() @@ -1219,7 +1219,6 @@ bool GetStartOnSystemStartup() if (line.find("Hidden") != string::npos && line.find("true") != string::npos) return false; ->>>>>>> bitcoin } optionFile.close(); @@ -1245,7 +1244,7 @@ bool SetStartOnSystemStartup(bool fAutoStart) // Write a bitcoin.desktop file to the autostart directory: optionFile << "[Desktop Entry]\n"; optionFile << "Type=Application\n"; - optionFile << "Name=Bitcoin\n"; + optionFile << "Name=PPCoin\n"; optionFile << "Exec=" << pszExePath << " -min\n"; optionFile << "Terminal=false\n"; optionFile << "Hidden=false\n"; diff --git a/src/util.h b/src/util.h index dc40af5..8c00938 100644 --- a/src/util.h +++ b/src/util.h @@ -450,6 +450,12 @@ inline std::string DateTimeStrFormat(const char* pszFormat, int64 nTime) return pszTime; } +static const std::string strTimestampFormat = "%F %H:%M:%S"; +inline std::string DateTimeStrFormat(int64 nTime) +{ + return DateTimeStrFormat(strTimestampFormat.c_str(), nTime); +} + template void skipspaces(T& it) { diff --git a/src/wallet.cpp b/src/wallet.cpp index a60cfca..a24a1d0 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -1049,11 +1049,14 @@ bool CWallet::SelectCoinsMinConf(int64 nTargetValue, unsigned int nSpendTime, in } //// debug print - printf("SelectCoins() best subset: "); - for (unsigned int i = 0; i < vValue.size(); i++) - if (vfBest[i]) - printf("%s ", FormatMoney(vValue[i].first).c_str()); - printf("total %s\n", FormatMoney(nBest).c_str()); + if (fDebug && GetBoolArg("-printselectcoin")) + { + printf("SelectCoins() best subset: "); + for (unsigned int i = 0; i < vValue.size(); i++) + if (vfBest[i]) + printf("%s ", FormatMoney(vValue[i].first).c_str()); + printf("total %s\n", FormatMoney(nBest).c_str()); + } } return true; diff --git a/src/walletdb.cpp b/src/walletdb.cpp index 865911c..ac355ab 100644 --- a/src/walletdb.cpp +++ b/src/walletdb.cpp @@ -1,5 +1,6 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2012 The Bitcoin developers +// Copyright (c) 2012 The PPCoin developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -191,7 +192,7 @@ int CWalletDB::LoadWallet(CWallet* pwallet) //printf("LoadWallet %s\n", wtx.GetHash().ToString().c_str()); //printf(" %12"PRI64d" %s %s %s\n", // wtx.vout[0].nValue, - // DateTimeStrFormat("%x %H:%M:%S", wtx.GetBlockTime()).c_str(), + // DateTimeStrFormat(wtx.GetBlockTime()).c_str(), // wtx.hashBlock.ToString().substr(0,20).c_str(), // wtx.mapValue["message"].c_str()); } @@ -367,7 +368,7 @@ void ThreadFlushWalletDB(void* parg) map::iterator mi = mapFileUseCount.find(strFile); if (mi != mapFileUseCount.end()) { - printf("%s ", DateTimeStrFormat("%x %H:%M:%S", GetTime()).c_str()); + printf("%s ", DateTimeStrFormat(GetTime()).c_str()); printf("Flushing wallet.dat\n"); nLastFlushed = nWalletDBUpdated; int64 nStart = GetTimeMillis(); -- 1.7.1