mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 13:03:17 +01:00
Merge branch 'LogPrint' of https://github.com/rebroad/bitcoin into rebroad-LogPrint
This commit is contained in:
commit
95a32f44d2
@ -261,7 +261,7 @@ void CAddrMan::MakeTried(CAddrInfo& info, int nId, int nOrigin)
|
||||
|
||||
void CAddrMan::Good_(const CService &addr, int64 nTime)
|
||||
{
|
||||
// printf("Good: addr=%s\n", addr.ToString().c_str());
|
||||
// LogPrintf("Good: addr=%s\n", addr.ToString().c_str());
|
||||
|
||||
int nId;
|
||||
CAddrInfo *pinfo = Find(addr, &nId);
|
||||
@ -304,7 +304,7 @@ void CAddrMan::Good_(const CService &addr, int64 nTime)
|
||||
// TODO: maybe re-add the node, but for now, just bail out
|
||||
if (nUBucket == -1) return;
|
||||
|
||||
printf("Moving %s to tried\n", addr.ToString().c_str());
|
||||
LogPrintf("Moving %s to tried\n", addr.ToString().c_str());
|
||||
|
||||
// move nId to the tried tables
|
||||
MakeTried(info, nId, nUBucket);
|
||||
@ -351,7 +351,7 @@ bool CAddrMan::Add_(const CAddress &addr, const CNetAddr& source, int64 nTimePen
|
||||
} else {
|
||||
pinfo = Create(addr, source, &nId);
|
||||
pinfo->nTime = max((int64)0, (int64)pinfo->nTime - nTimePenalty);
|
||||
// printf("Added %s [nTime=%fhr]\n", pinfo->ToString().c_str(), (GetAdjustedTime() - pinfo->nTime) / 3600.0);
|
||||
// LogPrintf("Added %s [nTime=%fhr]\n", pinfo->ToString().c_str(), (GetAdjustedTime() - pinfo->nTime) / 3600.0);
|
||||
nNew++;
|
||||
fNew = true;
|
||||
}
|
||||
|
@ -403,7 +403,7 @@ public:
|
||||
LOCK(cs);
|
||||
int err;
|
||||
if ((err=Check_()))
|
||||
printf("ADDRMAN CONSISTENCY CHECK FAILED!!! err=%i\n", err);
|
||||
LogPrintf("ADDRMAN CONSISTENCY CHECK FAILED!!! err=%i\n", err);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -419,7 +419,7 @@ public:
|
||||
Check();
|
||||
}
|
||||
if (fRet)
|
||||
printf("Added %s from %s: %i tried, %i new\n", addr.ToStringIPPort().c_str(), source.ToString().c_str(), nTried, nNew);
|
||||
LogPrintf("Added %s from %s: %i tried, %i new\n", addr.ToStringIPPort().c_str(), source.ToString().c_str(), nTried, nNew);
|
||||
return fRet;
|
||||
}
|
||||
|
||||
@ -435,7 +435,7 @@ public:
|
||||
Check();
|
||||
}
|
||||
if (nAdd)
|
||||
printf("Added %i addresses from %s: %i tried, %i new\n", nAdd, source.ToString().c_str(), nTried, nNew);
|
||||
LogPrintf("Added %i addresses from %s: %i tried, %i new\n", nAdd, source.ToString().c_str(), nTried, nNew);
|
||||
return nAdd > 0;
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,7 @@ std::string CUnsignedAlert::ToString() const
|
||||
|
||||
void CUnsignedAlert::print() const
|
||||
{
|
||||
printf("%s", ToString().c_str());
|
||||
LogPrintf("%s", ToString().c_str());
|
||||
}
|
||||
|
||||
void CAlert::SetNull()
|
||||
@ -203,13 +203,13 @@ bool CAlert::ProcessAlert(bool fThread)
|
||||
const CAlert& alert = (*mi).second;
|
||||
if (Cancels(alert))
|
||||
{
|
||||
printf("cancelling alert %d\n", alert.nID);
|
||||
LogPrintf("cancelling alert %d\n", alert.nID);
|
||||
uiInterface.NotifyAlertChanged((*mi).first, CT_DELETED);
|
||||
mapAlerts.erase(mi++);
|
||||
}
|
||||
else if (!alert.IsInEffect())
|
||||
{
|
||||
printf("expiring alert %d\n", alert.nID);
|
||||
LogPrintf("expiring alert %d\n", alert.nID);
|
||||
uiInterface.NotifyAlertChanged((*mi).first, CT_DELETED);
|
||||
mapAlerts.erase(mi++);
|
||||
}
|
||||
@ -223,7 +223,7 @@ bool CAlert::ProcessAlert(bool fThread)
|
||||
const CAlert& alert = item.second;
|
||||
if (alert.Cancels(*this))
|
||||
{
|
||||
printf("alert already cancelled by %d\n", alert.nID);
|
||||
LogPrintf("alert already cancelled by %d\n", alert.nID);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -253,6 +253,6 @@ bool CAlert::ProcessAlert(bool fThread)
|
||||
}
|
||||
}
|
||||
|
||||
printf("accepted alert %d, AppliesToMe()=%d\n", nID, AppliesToMe());
|
||||
LogPrintf("accepted alert %d, AppliesToMe()=%d\n", nID, AppliesToMe());
|
||||
return true;
|
||||
}
|
||||
|
@ -778,12 +778,12 @@ void StartRPCThreads()
|
||||
filesystem::path pathCertFile(GetArg("-rpcsslcertificatechainfile", "server.cert"));
|
||||
if (!pathCertFile.is_complete()) pathCertFile = filesystem::path(GetDataDir()) / pathCertFile;
|
||||
if (filesystem::exists(pathCertFile)) rpc_ssl_context->use_certificate_chain_file(pathCertFile.string());
|
||||
else printf("ThreadRPCServer ERROR: missing server certificate file %s\n", pathCertFile.string().c_str());
|
||||
else LogPrintf("ThreadRPCServer ERROR: missing server certificate file %s\n", pathCertFile.string().c_str());
|
||||
|
||||
filesystem::path pathPKFile(GetArg("-rpcsslprivatekeyfile", "server.pem"));
|
||||
if (!pathPKFile.is_complete()) pathPKFile = filesystem::path(GetDataDir()) / pathPKFile;
|
||||
if (filesystem::exists(pathPKFile)) rpc_ssl_context->use_private_key_file(pathPKFile.string(), ssl::context::pem);
|
||||
else printf("ThreadRPCServer ERROR: missing server private key file %s\n", pathPKFile.string().c_str());
|
||||
else LogPrintf("ThreadRPCServer ERROR: missing server private key file %s\n", pathPKFile.string().c_str());
|
||||
|
||||
string strCiphers = GetArg("-rpcsslciphers", "TLSv1+HIGH:!SSLv2:!aNULL:!eNULL:!AH:!3DES:@STRENGTH");
|
||||
SSL_CTX_set_cipher_list(rpc_ssl_context->impl(), strCiphers.c_str());
|
||||
@ -892,7 +892,7 @@ void JSONRequest::parse(const Value& valRequest)
|
||||
throw JSONRPCError(RPC_INVALID_REQUEST, "Method must be a string");
|
||||
strMethod = valMethod.get_str();
|
||||
if (strMethod != "getwork" && strMethod != "getworkex" && strMethod != "getblocktemplate")
|
||||
printf("ThreadRPCServer method=%s\n", strMethod.c_str());
|
||||
LogPrintf("ThreadRPCServer method=%s\n", strMethod.c_str());
|
||||
|
||||
// Parse params
|
||||
Value valParams = find_value(request, "params");
|
||||
@ -966,7 +966,7 @@ void ServiceConnection(AcceptedConnection *conn)
|
||||
}
|
||||
if (!HTTPAuthorized(mapHeaders))
|
||||
{
|
||||
printf("ThreadRPCServer incorrect password attempt from %s\n", conn->peer_address_to_string().c_str());
|
||||
LogPrintf("ThreadRPCServer incorrect password attempt from %s\n", conn->peer_address_to_string().c_str());
|
||||
/* Deter brute-forcing short passwords.
|
||||
If this results in a DOS the user really
|
||||
shouldn't have their RPC port exposed.*/
|
||||
@ -1290,7 +1290,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
if (argc >= 2 && string(argv[1]) == "-server")
|
||||
{
|
||||
printf("server ready\n");
|
||||
LogPrintf("server ready\n");
|
||||
ThreadRPCServer(NULL);
|
||||
}
|
||||
else
|
||||
|
@ -191,7 +191,7 @@ bool AcceptPendingSyncCheckpoint()
|
||||
hashPendingCheckpoint = 0;
|
||||
checkpointMessage = checkpointMessagePending;
|
||||
checkpointMessagePending.SetNull();
|
||||
printf("AcceptPendingSyncCheckpoint : sync-checkpoint at %s\n", hashSyncCheckpoint.ToString().c_str());
|
||||
LogPrintf("AcceptPendingSyncCheckpoint : sync-checkpoint at %s\n", hashSyncCheckpoint.ToString().c_str());
|
||||
// relay the checkpoint
|
||||
if (!checkpointMessage.IsNull())
|
||||
{
|
||||
@ -260,7 +260,7 @@ bool ResetSyncCheckpoint()
|
||||
if (mapBlockIndex.count(hash) && !mapBlockIndex[hash]->IsInMainChain())
|
||||
{
|
||||
// checkpoint block accepted but not yet in main chain
|
||||
printf("ResetSyncCheckpoint: SetBestChain to hardened checkpoint %s\n", hash.ToString().c_str());
|
||||
LogPrintf("ResetSyncCheckpoint: SetBestChain to hardened checkpoint %s\n", hash.ToString().c_str());
|
||||
CValidationState state;
|
||||
if (!SetBestChain(state, mapBlockIndex[hash]))
|
||||
{
|
||||
@ -274,7 +274,7 @@ bool ResetSyncCheckpoint()
|
||||
|
||||
if (!WriteSyncCheckpoint(hash))
|
||||
return error("ResetSyncCheckpoint: failed to write sync checkpoint %s", hash.ToString().c_str());
|
||||
printf("ResetSyncCheckpoint: sync-checkpoint reset to %s\n", hashSyncCheckpoint.ToString().c_str());
|
||||
LogPrintf("ResetSyncCheckpoint: sync-checkpoint reset to %s\n", hashSyncCheckpoint.ToString().c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -346,7 +346,7 @@ bool SendSyncCheckpoint(uint256 hashCheckpoint)
|
||||
|
||||
if(!checkpoint.ProcessSyncCheckpoint(NULL))
|
||||
{
|
||||
printf("WARNING: SendSyncCheckpoint: Failed to process checkpoint.\n");
|
||||
LogPrintf("WARNING: SendSyncCheckpoint: Failed to process checkpoint.\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -414,7 +414,7 @@ bool CSyncCheckpoint::ProcessSyncCheckpoint(CNode* pfrom)
|
||||
// We haven't received the checkpoint chain, keep the checkpoint as pending
|
||||
hashPendingCheckpoint = hashCheckpoint;
|
||||
checkpointMessagePending = *this;
|
||||
printf("ProcessSyncCheckpoint: pending for sync-checkpoint %s\n", hashCheckpoint.ToString().c_str());
|
||||
LogPrintf("ProcessSyncCheckpoint: pending for sync-checkpoint %s\n", hashCheckpoint.ToString().c_str());
|
||||
// Ask this guy to fill in what we're missing
|
||||
if (pfrom)
|
||||
{
|
||||
@ -446,7 +446,7 @@ bool CSyncCheckpoint::ProcessSyncCheckpoint(CNode* pfrom)
|
||||
checkpointMessage = *this;
|
||||
hashPendingCheckpoint = 0;
|
||||
checkpointMessagePending.SetNull();
|
||||
printf("ProcessSyncCheckpoint: sync-checkpoint at %s\n", hashCheckpoint.ToString().c_str());
|
||||
LogPrintf("ProcessSyncCheckpoint: sync-checkpoint at %s\n", hashCheckpoint.ToString().c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -75,7 +75,7 @@ public:
|
||||
|
||||
void print() const
|
||||
{
|
||||
printf("%s", ToString().c_str());
|
||||
LogPrintf("%s", ToString().c_str());
|
||||
}
|
||||
};
|
||||
|
||||
|
30
src/db.cpp
30
src/db.cpp
@ -35,7 +35,7 @@ void CDBEnv::EnvShutdown()
|
||||
fDbEnvInit = false;
|
||||
int ret = dbenv.close(0);
|
||||
if (ret != 0)
|
||||
printf("EnvShutdown exception: %s (%d)\n", DbEnv::strerror(ret), ret);
|
||||
LogPrintf("EnvShutdown exception: %s (%d)\n", DbEnv::strerror(ret), ret);
|
||||
if (!fMockDb)
|
||||
DbEnv(0).remove(path.string().c_str(), 0);
|
||||
}
|
||||
@ -67,7 +67,7 @@ bool CDBEnv::Open(const boost::filesystem::path& pathIn)
|
||||
filesystem::path pathLogDir = path / "database";
|
||||
filesystem::create_directory(pathLogDir);
|
||||
filesystem::path pathErrorFile = path / "db.log";
|
||||
printf("dbenv.open LogDir=%s ErrorFile=%s\n", pathLogDir.string().c_str(), pathErrorFile.string().c_str());
|
||||
LogPrintf("dbenv.open LogDir=%s ErrorFile=%s\n", pathLogDir.string().c_str(), pathErrorFile.string().c_str());
|
||||
|
||||
unsigned int nEnvFlags = 0;
|
||||
if (GetBoolArg("-privdb", true))
|
||||
@ -108,7 +108,7 @@ void CDBEnv::MakeMock()
|
||||
|
||||
boost::this_thread::interruption_point();
|
||||
|
||||
printf("CDBEnv::MakeMock()\n");
|
||||
LogPrintf("CDBEnv::MakeMock()\n");
|
||||
|
||||
dbenv.set_cachesize(1, 0, 1);
|
||||
dbenv.set_lg_bsize(10485760*4);
|
||||
@ -165,16 +165,16 @@ bool CDBEnv::Salvage(std::string strFile, bool fAggressive,
|
||||
int result = db.verify(strFile.c_str(), NULL, &strDump, flags);
|
||||
if (result == DB_VERIFY_BAD)
|
||||
{
|
||||
printf("Error: Salvage found errors, all data may not be recoverable.\n");
|
||||
LogPrintf("Error: Salvage found errors, all data may not be recoverable.\n");
|
||||
if (!fAggressive)
|
||||
{
|
||||
printf("Error: Rerun with aggressive mode to ignore errors and continue.\n");
|
||||
LogPrintf("Error: Rerun with aggressive mode to ignore errors and continue.\n");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (result != 0 && result != DB_VERIFY_BAD)
|
||||
{
|
||||
printf("ERROR: db salvage failed: %d\n",result);
|
||||
LogPrintf("ERROR: db salvage failed: %d\n",result);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -345,7 +345,7 @@ bool CDB::Rewrite(const string& strFile, const char* pszSkip)
|
||||
bitdb.mapFileUseCount.erase(strFile);
|
||||
|
||||
bool fSuccess = true;
|
||||
printf("Rewriting %s...\n", strFile.c_str());
|
||||
LogPrintf("Rewriting %s...\n", strFile.c_str());
|
||||
string strFileRes = strFile + ".rewrite";
|
||||
{ // surround usage of db with extra {}
|
||||
CDB db(strFile.c_str(), "r");
|
||||
@ -359,7 +359,7 @@ bool CDB::Rewrite(const string& strFile, const char* pszSkip)
|
||||
0);
|
||||
if (ret > 0)
|
||||
{
|
||||
printf("Cannot create database file %s\n", strFileRes.c_str());
|
||||
LogPrintf("Cannot create database file %s\n", strFileRes.c_str());
|
||||
fSuccess = false;
|
||||
}
|
||||
|
||||
@ -415,7 +415,7 @@ bool CDB::Rewrite(const string& strFile, const char* pszSkip)
|
||||
fSuccess = false;
|
||||
}
|
||||
if (!fSuccess)
|
||||
printf("Rewriting of %s FAILED!\n", strFileRes.c_str());
|
||||
LogPrintf("Rewriting of %s FAILED!\n", strFileRes.c_str());
|
||||
return fSuccess;
|
||||
}
|
||||
}
|
||||
@ -430,7 +430,7 @@ void CDBEnv::Flush(bool fShutdown)
|
||||
int64 nStart = GetTimeMillis();
|
||||
// Flush log data to the actual data file
|
||||
// on all files that are not in use
|
||||
printf("Flush(%s)%s\n", fShutdown ? "true" : "false", fDbEnvInit ? "" : " db not started");
|
||||
LogPrintf("Flush(%s)%s\n", fShutdown ? "true" : "false", fDbEnvInit ? "" : " db not started");
|
||||
if (!fDbEnvInit)
|
||||
return;
|
||||
{
|
||||
@ -440,23 +440,23 @@ void CDBEnv::Flush(bool fShutdown)
|
||||
{
|
||||
string strFile = (*mi).first;
|
||||
int nRefCount = (*mi).second;
|
||||
printf("%s refcount=%d\n", strFile.c_str(), nRefCount);
|
||||
LogPrintf("%s refcount=%d\n", strFile.c_str(), nRefCount);
|
||||
if (nRefCount == 0)
|
||||
{
|
||||
// Move log data to the dat file
|
||||
CloseDb(strFile);
|
||||
printf("%s checkpoint\n", strFile.c_str());
|
||||
LogPrintf("%s checkpoint\n", strFile.c_str());
|
||||
dbenv.txn_checkpoint(0, 0, 0);
|
||||
printf("%s detach\n", strFile.c_str());
|
||||
LogPrintf("%s detach\n", strFile.c_str());
|
||||
if (!fMockDb)
|
||||
dbenv.lsn_reset(strFile.c_str(), 0);
|
||||
printf("%s closed\n", strFile.c_str());
|
||||
LogPrintf("%s closed\n", strFile.c_str());
|
||||
mapFileUseCount.erase(mi++);
|
||||
}
|
||||
else
|
||||
mi++;
|
||||
}
|
||||
printf("DBFlush(%s)%s ended %15"PRI64d"ms\n", fShutdown ? "true" : "false", fDbEnvInit ? "" : " db not started", GetTimeMillis() - nStart);
|
||||
LogPrintf("DBFlush(%s)%s ended %15"PRI64d"ms\n", fShutdown ? "true" : "false", fDbEnvInit ? "" : " db not started", GetTimeMillis() - nStart);
|
||||
if (fShutdown)
|
||||
{
|
||||
char** listp;
|
||||
|
72
src/init.cpp
72
src/init.cpp
@ -90,7 +90,7 @@ static CCoinsViewDB *pcoinsdbview;
|
||||
|
||||
void Shutdown()
|
||||
{
|
||||
printf("Shutdown : In progress...\n");
|
||||
LogPrintf("Shutdown : In progress...\n");
|
||||
static CCriticalSection cs_Shutdown;
|
||||
TRY_LOCK(cs_Shutdown, lockShutdown);
|
||||
if (!lockShutdown) return;
|
||||
@ -121,7 +121,7 @@ void Shutdown()
|
||||
UnregisterWallet(pwalletMain);
|
||||
if (pwalletMain)
|
||||
delete pwalletMain;
|
||||
printf("Shutdown : done\n");
|
||||
LogPrintf("Shutdown : done\n");
|
||||
}
|
||||
|
||||
//
|
||||
@ -413,13 +413,13 @@ void ThreadImport(std::vector<boost::filesystem::path> vImportFiles)
|
||||
FILE *file = OpenBlockFile(pos, true);
|
||||
if (!file)
|
||||
break;
|
||||
printf("Reindexing block file blk%05u.dat...\n", (unsigned int)nFile);
|
||||
LogPrintf("Reindexing block file blk%05u.dat...\n", (unsigned int)nFile);
|
||||
LoadExternalBlockFile(file, &pos);
|
||||
nFile++;
|
||||
}
|
||||
pblocktree->WriteReindexing(false);
|
||||
fReindex = false;
|
||||
printf("Reindexing finished\n");
|
||||
LogPrintf("Reindexing finished\n");
|
||||
// To avoid ending up in a situation without genesis block, re-try initializing (no-op if reindexing worked):
|
||||
InitBlockIndex();
|
||||
}
|
||||
@ -431,7 +431,7 @@ void ThreadImport(std::vector<boost::filesystem::path> vImportFiles)
|
||||
if (file) {
|
||||
CImportingNow imp;
|
||||
filesystem::path pathBootstrapOld = GetDataDir() / "bootstrap.dat.old";
|
||||
printf("Importing bootstrap.dat...\n");
|
||||
LogPrintf("Importing bootstrap.dat...\n");
|
||||
LoadExternalBlockFile(file);
|
||||
RenameOver(pathBootstrap, pathBootstrapOld);
|
||||
}
|
||||
@ -442,7 +442,7 @@ void ThreadImport(std::vector<boost::filesystem::path> vImportFiles)
|
||||
FILE *file = fopen(path.string().c_str(), "rb");
|
||||
if (file) {
|
||||
CImportingNow imp;
|
||||
printf("Importing %s...\n", path.string().c_str());
|
||||
LogPrintf("Importing %s...\n", path.string().c_str());
|
||||
LoadExternalBlockFile(file);
|
||||
}
|
||||
}
|
||||
@ -657,21 +657,21 @@ bool AppInit2(boost::thread_group& threadGroup)
|
||||
|
||||
if (GetBoolArg("-shrinkdebugfile", !fDebug))
|
||||
ShrinkDebugFile();
|
||||
printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
|
||||
printf("DarkCoin version %s (%s)\n", FormatFullVersion().c_str(), CLIENT_DATE.c_str());
|
||||
printf("Using OpenSSL version %s\n", SSLeay_version(SSLEAY_VERSION));
|
||||
LogPrintf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
|
||||
LogPrintf("DarkCoin version %s (%s)\n", FormatFullVersion().c_str(), CLIENT_DATE.c_str());
|
||||
LogPrintf("Using OpenSSL version %s\n", SSLeay_version(SSLEAY_VERSION));
|
||||
if (!fLogTimestamps)
|
||||
printf("Startup time: %s\n", DateTimeStrFormat("%Y-%m-%d %H:%M:%S", GetTime()).c_str());
|
||||
printf("Default data directory %s\n", GetDefaultDataDir().string().c_str());
|
||||
printf("Using data directory %s\n", strDataDir.c_str());
|
||||
printf("Using at most %i connections (%i file descriptors available)\n", nMaxConnections, nFD);
|
||||
LogPrintf("Startup time: %s\n", DateTimeStrFormat("%Y-%m-%d %H:%M:%S", GetTime()).c_str());
|
||||
LogPrintf("Default data directory %s\n", GetDefaultDataDir().string().c_str());
|
||||
LogPrintf("Using data directory %s\n", strDataDir.c_str());
|
||||
LogPrintf("Using at most %i connections (%i file descriptors available)\n", nMaxConnections, nFD);
|
||||
std::ostringstream strErrors;
|
||||
|
||||
if (fDaemon)
|
||||
fprintf(stdout, "DarkCoin server starting\n");
|
||||
|
||||
if (nScriptCheckThreads) {
|
||||
printf("Using %u threads for script verification\n", nScriptCheckThreads);
|
||||
LogPrintf("Using %u threads for script verification\n", nScriptCheckThreads);
|
||||
for (int i=0; i<nScriptCheckThreads-1; i++)
|
||||
threadGroup.create_thread(&ThreadScriptCheck);
|
||||
}
|
||||
@ -694,7 +694,7 @@ bool AppInit2(boost::thread_group& threadGroup)
|
||||
boost::filesystem::path pathDatabaseBak = GetDataDir() / strprintf("database.%"PRI64d".bak", GetTime());
|
||||
try {
|
||||
boost::filesystem::rename(pathDatabase, pathDatabaseBak);
|
||||
printf("Moved old %s to %s. Retrying.\n", pathDatabase.string().c_str(), pathDatabaseBak.string().c_str());
|
||||
LogPrintf("Moved old %s to %s. Retrying.\n", pathDatabase.string().c_str(), pathDatabaseBak.string().c_str());
|
||||
} catch(boost::filesystem::filesystem_error &error) {
|
||||
// failure is ok (well, not really, but it's not worse than what we started with)
|
||||
}
|
||||
@ -861,12 +861,12 @@ bool AppInit2(boost::thread_group& threadGroup)
|
||||
filesystem::path dest = blocksDir / strprintf("blk%05u.dat", i-1);
|
||||
try {
|
||||
filesystem::create_hard_link(source, dest);
|
||||
printf("Hardlinked %s -> %s\n", source.string().c_str(), dest.string().c_str());
|
||||
LogPrintf("Hardlinked %s -> %s\n", source.string().c_str(), dest.string().c_str());
|
||||
linked = true;
|
||||
} catch (filesystem::filesystem_error & e) {
|
||||
// Note: hardlink creation failing is not a disaster, it just means
|
||||
// blocks will get re-downloaded from peers.
|
||||
printf("Error hardlinking blk%04u.dat : %s\n", i, e.what());
|
||||
LogPrintf("Error hardlinking blk%04u.dat : %s\n", i, e.what());
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -969,10 +969,10 @@ bool AppInit2(boost::thread_group& threadGroup)
|
||||
// As the program has not fully started yet, Shutdown() is possibly overkill.
|
||||
if (fRequestShutdown)
|
||||
{
|
||||
printf("Shutdown requested. Exiting.\n");
|
||||
LogPrintf("Shutdown requested. Exiting.\n");
|
||||
return false;
|
||||
}
|
||||
printf(" block index %15"PRI64d"ms\n", GetTimeMillis() - nStart);
|
||||
LogPrintf(" block index %15"PRI64d"ms\n", GetTimeMillis() - nStart);
|
||||
|
||||
if (GetBoolArg("-printblockindex") || GetBoolArg("-printblocktree"))
|
||||
{
|
||||
@ -994,19 +994,19 @@ bool AppInit2(boost::thread_group& threadGroup)
|
||||
block.ReadFromDisk(pindex);
|
||||
block.BuildMerkleTree();
|
||||
block.print();
|
||||
printf("\n");
|
||||
LogPrintf("\n");
|
||||
nFound++;
|
||||
}
|
||||
}
|
||||
if (nFound == 0)
|
||||
printf("No blocks matching %s were found\n", strMatch.c_str());
|
||||
LogPrintf("No blocks matching %s were found\n", strMatch.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
// ********************************************************* Step 8: load wallet
|
||||
|
||||
if (fDisableWallet) {
|
||||
printf("Wallet disabled!\n");
|
||||
LogPrintf("Wallet disabled!\n");
|
||||
pwalletMain = NULL;
|
||||
} else {
|
||||
uiInterface.InitMessage(_("Loading wallet..."));
|
||||
@ -1030,7 +1030,7 @@ bool AppInit2(boost::thread_group& threadGroup)
|
||||
else if (nLoadWalletRet == DB_NEED_REWRITE)
|
||||
{
|
||||
strErrors << _("Wallet needed to be rewritten: restart DarkCoin to complete") << "\n";
|
||||
printf("%s", strErrors.str().c_str());
|
||||
LogPrintf("%s", strErrors.str().c_str());
|
||||
return InitError(strErrors.str());
|
||||
}
|
||||
else
|
||||
@ -1042,12 +1042,12 @@ bool AppInit2(boost::thread_group& threadGroup)
|
||||
int nMaxVersion = GetArg("-upgradewallet", 0);
|
||||
if (nMaxVersion == 0) // the -upgradewallet without argument case
|
||||
{
|
||||
printf("Performing wallet upgrade to %i\n", FEATURE_LATEST);
|
||||
LogPrintf("Performing wallet upgrade to %i\n", FEATURE_LATEST);
|
||||
nMaxVersion = CLIENT_VERSION;
|
||||
pwalletMain->SetMinVersion(FEATURE_LATEST); // permanently upgrade the wallet immediately
|
||||
}
|
||||
else
|
||||
printf("Allowing wallet upgrade up to %i\n", nMaxVersion);
|
||||
LogPrintf("Allowing wallet upgrade up to %i\n", nMaxVersion);
|
||||
if (nMaxVersion < pwalletMain->GetVersion())
|
||||
strErrors << _("Cannot downgrade wallet") << "\n";
|
||||
pwalletMain->SetMaxVersion(nMaxVersion);
|
||||
@ -1068,8 +1068,8 @@ bool AppInit2(boost::thread_group& threadGroup)
|
||||
pwalletMain->SetBestChain(CBlockLocator(pindexBest));
|
||||
}
|
||||
|
||||
printf("%s", strErrors.str().c_str());
|
||||
printf(" wallet %15"PRI64d"ms\n", GetTimeMillis() - nStart);
|
||||
LogPrintf("%s", strErrors.str().c_str());
|
||||
LogPrintf(" wallet %15"PRI64d"ms\n", GetTimeMillis() - nStart);
|
||||
|
||||
RegisterWallet(pwalletMain);
|
||||
|
||||
@ -1088,10 +1088,10 @@ bool AppInit2(boost::thread_group& threadGroup)
|
||||
if (pindexBest && pindexBest != pindexRescan)
|
||||
{
|
||||
uiInterface.InitMessage(_("Rescanning..."));
|
||||
printf("Rescanning last %i blocks (from block %i)...\n", pindexBest->nHeight - pindexRescan->nHeight, pindexRescan->nHeight);
|
||||
LogPrintf("Rescanning last %i blocks (from block %i)...\n", pindexBest->nHeight - pindexRescan->nHeight, pindexRescan->nHeight);
|
||||
nStart = GetTimeMillis();
|
||||
pwalletMain->ScanForWalletTransactions(pindexRescan, true);
|
||||
printf(" rescan %15"PRI64d"ms\n", GetTimeMillis() - nStart);
|
||||
LogPrintf(" rescan %15"PRI64d"ms\n", GetTimeMillis() - nStart);
|
||||
pwalletMain->SetBestChain(CBlockLocator(pindexBest));
|
||||
nWalletDBUpdated++;
|
||||
}
|
||||
@ -1121,10 +1121,10 @@ bool AppInit2(boost::thread_group& threadGroup)
|
||||
{
|
||||
CAddrDB adb;
|
||||
if (!adb.Read(addrman))
|
||||
printf("Invalid or missing peers.dat; recreating\n");
|
||||
LogPrintf("Invalid or missing peers.dat; recreating\n");
|
||||
}
|
||||
|
||||
printf("Loaded %i addresses from peers.dat %"PRI64d"ms\n",
|
||||
LogPrintf("Loaded %i addresses from peers.dat %"PRI64d"ms\n",
|
||||
addrman.size(), GetTimeMillis() - nStart);
|
||||
|
||||
// ********************************************************* Step 11: start node
|
||||
@ -1138,11 +1138,11 @@ bool AppInit2(boost::thread_group& threadGroup)
|
||||
RandAddSeedPerfmon();
|
||||
|
||||
//// debug print
|
||||
printf("mapBlockIndex.size() = %"PRIszu"\n", mapBlockIndex.size());
|
||||
printf("nBestHeight = %d\n", nBestHeight);
|
||||
printf("setKeyPool.size() = %"PRIszu"\n", pwalletMain ? pwalletMain->setKeyPool.size() : 0);
|
||||
printf("mapWallet.size() = %"PRIszu"\n", pwalletMain ? pwalletMain->mapWallet.size() : 0);
|
||||
printf("mapAddressBook.size() = %"PRIszu"\n", pwalletMain ? pwalletMain->mapAddressBook.size() : 0);
|
||||
LogPrintf("mapBlockIndex.size() = %"PRIszu"\n", mapBlockIndex.size());
|
||||
LogPrintf("nBestHeight = %d\n", nBestHeight);
|
||||
LogPrintf("setKeyPool.size() = %"PRIszu"\n", pwalletMain ? pwalletMain->setKeyPool.size() : 0);
|
||||
LogPrintf("mapWallet.size() = %"PRIszu"\n", pwalletMain ? pwalletMain->mapWallet.size() : 0);
|
||||
LogPrintf("mapAddressBook.size() = %"PRIszu"\n", pwalletMain ? pwalletMain->mapAddressBook.size() : 0);
|
||||
|
||||
StartNode(threadGroup);
|
||||
|
||||
|
@ -47,16 +47,16 @@ CLevelDB::CLevelDB(const boost::filesystem::path &path, size_t nCacheSize, bool
|
||||
options.env = penv;
|
||||
} else {
|
||||
if (fWipe) {
|
||||
printf("Wiping LevelDB in %s\n", path.string().c_str());
|
||||
LogPrintf("Wiping LevelDB in %s\n", path.string().c_str());
|
||||
leveldb::DestroyDB(path.string(), options);
|
||||
}
|
||||
boost::filesystem::create_directory(path);
|
||||
printf("Opening LevelDB in %s\n", path.string().c_str());
|
||||
LogPrintf("Opening LevelDB in %s\n", path.string().c_str());
|
||||
}
|
||||
leveldb::Status status = leveldb::DB::Open(options, path.string(), &pdb);
|
||||
if (!status.ok())
|
||||
throw std::runtime_error(strprintf("CLevelDB(): error opening database environment %s", status.ToString().c_str()));
|
||||
printf("Opened LevelDB successfully\n");
|
||||
LogPrintf("Opened LevelDB successfully\n");
|
||||
}
|
||||
|
||||
CLevelDB::~CLevelDB() {
|
||||
@ -73,7 +73,7 @@ CLevelDB::~CLevelDB() {
|
||||
bool CLevelDB::WriteBatch(CLevelDBBatch &batch, bool fSync) throw(leveldb_error) {
|
||||
leveldb::Status status = pdb->Write(fSync ? syncoptions : writeoptions, &batch.batch);
|
||||
if (!status.ok()) {
|
||||
printf("LevelDB write failure: %s\n", status.ToString().c_str());
|
||||
LogPrintf("LevelDB write failure: %s\n", status.ToString().c_str());
|
||||
HandleError(status);
|
||||
return false;
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
#define BITCOIN_LEVELDB_H
|
||||
|
||||
#include "serialize.h"
|
||||
#include "util.h"
|
||||
|
||||
#include <leveldb/db.h>
|
||||
#include <leveldb/write_batch.h>
|
||||
@ -91,7 +92,7 @@ public:
|
||||
if (!status.ok()) {
|
||||
if (status.IsNotFound())
|
||||
return false;
|
||||
printf("LevelDB read failure: %s\n", status.ToString().c_str());
|
||||
LogPrintf("LevelDB read failure: %s\n", status.ToString().c_str());
|
||||
HandleError(status);
|
||||
}
|
||||
try {
|
||||
@ -120,7 +121,7 @@ public:
|
||||
if (!status.ok()) {
|
||||
if (status.IsNotFound())
|
||||
return false;
|
||||
printf("LevelDB read failure: %s\n", status.ToString().c_str());
|
||||
LogPrintf("LevelDB read failure: %s\n", status.ToString().c_str());
|
||||
HandleError(status);
|
||||
}
|
||||
return true;
|
||||
|
294
src/main.cpp
294
src/main.cpp
@ -315,7 +315,7 @@ bool AddOrphanTx(const CTransaction& tx)
|
||||
unsigned int sz = tx.GetSerializeSize(SER_NETWORK, CTransaction::CURRENT_VERSION);
|
||||
if (sz > 5000)
|
||||
{
|
||||
printf("ignoring large orphan tx (size: %u, hash: %s)\n", sz, hash.ToString().c_str());
|
||||
LogPrintf("ignoring large orphan tx (size: %u, hash: %s)\n", sz, hash.ToString().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -323,7 +323,7 @@ bool AddOrphanTx(const CTransaction& tx)
|
||||
BOOST_FOREACH(const CTxIn& txin, tx.vin)
|
||||
mapOrphanTransactionsByPrev[txin.prevout.hash].insert(hash);
|
||||
|
||||
printf("stored orphan tx %s (mapsz %"PRIszu")\n", hash.ToString().c_str(),
|
||||
LogPrintf("stored orphan tx %s (mapsz %"PRIszu")\n", hash.ToString().c_str(),
|
||||
mapOrphanTransactions.size());
|
||||
return true;
|
||||
}
|
||||
@ -533,7 +533,7 @@ int CMerkleTx::SetMerkleBranch(const CBlock* pblock)
|
||||
{
|
||||
vMerkleBranch.clear();
|
||||
nIndex = -1;
|
||||
printf("ERROR: SetMerkleBranch() : couldn't find tx in block\n");
|
||||
LogPrintf("ERROR: SetMerkleBranch() : couldn't find tx in block\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -792,7 +792,7 @@ bool CTxMemPool::accept(CValidationState &state, CTransaction &tx, bool fCheckIn
|
||||
if (dFreeCount >= GetArg("-limitfreerelay", 15)*10*1000)
|
||||
return error("CTxMemPool::accept() : free transaction rejected by rate limiter");
|
||||
if (fDebug)
|
||||
printf("Rate limit dFreeCount: %g => %g\n", dFreeCount, dFreeCount+nSize);
|
||||
LogPrintf("Rate limit dFreeCount: %g => %g\n", dFreeCount, dFreeCount+nSize);
|
||||
dFreeCount += nSize;
|
||||
}
|
||||
|
||||
@ -809,7 +809,7 @@ bool CTxMemPool::accept(CValidationState &state, CTransaction &tx, bool fCheckIn
|
||||
LOCK(cs);
|
||||
if (ptxOld)
|
||||
{
|
||||
printf("CTxMemPool::accept() : replacing tx %s with new version\n", ptxOld->GetHash().ToString().c_str());
|
||||
LogPrintf("CTxMemPool::accept() : replacing tx %s with new version\n", ptxOld->GetHash().ToString().c_str());
|
||||
remove(*ptxOld);
|
||||
}
|
||||
addUnchecked(hash, tx);
|
||||
@ -1347,7 +1347,7 @@ int64 static GetBlockValue(int nBits, int nHeight, int64 nFees)
|
||||
if (nSubsidy < 1) nSubsidy = 1;
|
||||
}
|
||||
|
||||
// printf("height %u diff %4.2f reward %i \n", nHeight, dDiff, nSubsidy);
|
||||
// LogPrintf("height %u diff %4.2f reward %i \n", nHeight, dDiff, nSubsidy);
|
||||
nSubsidy *= COIN;
|
||||
|
||||
// yearly decline of production by 7% per year, projected 21.3M coins max by year 2050.
|
||||
@ -1430,7 +1430,7 @@ unsigned int static GetNextWorkRequired_V1(const CBlockIndex* pindexLast, const
|
||||
|
||||
// Limit adjustment step
|
||||
int64 nActualTimespan = pindexLast->GetBlockTime() - pindexFirst->GetBlockTime();
|
||||
printf(" nActualTimespan = %"PRI64d" before bounds\n", nActualTimespan);
|
||||
LogPrintf(" nActualTimespan = %"PRI64d" before bounds\n", nActualTimespan);
|
||||
if (nActualTimespan < nTargetTimespan/4)
|
||||
nActualTimespan = nTargetTimespan/4;
|
||||
if (nActualTimespan > nTargetTimespan*4)
|
||||
@ -1446,10 +1446,10 @@ unsigned int static GetNextWorkRequired_V1(const CBlockIndex* pindexLast, const
|
||||
bnNew = bnProofOfWorkLimit;
|
||||
|
||||
/// debug print
|
||||
printf("GetNextWorkRequired RETARGET\n");
|
||||
printf("nTargetTimespan = %"PRI64d" nActualTimespan = %"PRI64d"\n", nTargetTimespan, nActualTimespan);
|
||||
printf("Before: %08x %s\n", pindexLast->nBits, CBigNum().SetCompact(pindexLast->nBits).getuint256().ToString().c_str());
|
||||
printf("After: %08x %s\n", bnNew.GetCompact(), bnNew.getuint256().ToString().c_str());
|
||||
LogPrintf("GetNextWorkRequired RETARGET\n");
|
||||
LogPrintf("nTargetTimespan = %"PRI64d" nActualTimespan = %"PRI64d"\n", nTargetTimespan, nActualTimespan);
|
||||
LogPrintf("Before: %08x %s\n", pindexLast->nBits, CBigNum().SetCompact(pindexLast->nBits).getuint256().ToString().c_str());
|
||||
LogPrintf("After: %08x %s\n", bnNew.GetCompact(), bnNew.getuint256().ToString().c_str());
|
||||
|
||||
return bnNew.GetCompact();
|
||||
}
|
||||
@ -1722,15 +1722,15 @@ void static InvalidChainFound(CBlockIndex* pindexNew)
|
||||
pblocktree->WriteBestInvalidWork(CBigNum(nBestInvalidWork));
|
||||
uiInterface.NotifyBlocksChanged();
|
||||
}
|
||||
printf("InvalidChainFound: invalid block=%s height=%d log2_work=%.8g date=%s\n",
|
||||
LogPrintf("InvalidChainFound: invalid block=%s height=%d log2_work=%.8g date=%s\n",
|
||||
pindexNew->GetBlockHash().ToString().c_str(), pindexNew->nHeight,
|
||||
log(pindexNew->nChainWork.getdouble())/log(2.0), DateTimeStrFormat("%Y-%m-%d %H:%M:%S",
|
||||
pindexNew->GetBlockTime()).c_str());
|
||||
printf("InvalidChainFound: current best=%s height=%d log2_work=%.8g date=%s\n",
|
||||
LogPrintf("InvalidChainFound: current best=%s height=%d log2_work=%.8g date=%s\n",
|
||||
hashBestChain.ToString().c_str(), nBestHeight, log(nBestChainWork.getdouble())/log(2.0),
|
||||
DateTimeStrFormat("%Y-%m-%d %H:%M:%S", pindexBest->GetBlockTime()).c_str());
|
||||
if (pindexBest && nBestInvalidWork > nBestChainWork + (pindexBest->GetBlockWork() * 6).getuint256())
|
||||
printf("InvalidChainFound: Warning: Displayed transactions may not be correct! You may need to upgrade, or other nodes may need to upgrade.\n");
|
||||
LogPrintf("InvalidChainFound: Warning: Displayed transactions may not be correct! You may need to upgrade, or other nodes may need to upgrade.\n");
|
||||
}
|
||||
|
||||
void static InvalidBlockFound(CBlockIndex *pindex) {
|
||||
@ -1816,18 +1816,18 @@ uint256 CBlockHeader::GetSpecialHash() const
|
||||
uint256 hash = 0;
|
||||
uint256 vmnAdditional = 0;
|
||||
|
||||
//printf("------------------------------------------------\n");
|
||||
//LogPrintf("------------------------------------------------\n");
|
||||
if( (fTestNet && nTime > START_MASTERNODE_PAYMENTS_TESTNET) || (!fTestNet && nTime > START_MASTERNODE_PAYMENTS)) {
|
||||
BOOST_FOREACH(CMasterNodeVote mv1, vmn){
|
||||
uint160 n2 = mv1.pubkey.GetID();
|
||||
uint256 n = 0;
|
||||
memcpy(&n, &n2, sizeof(n2));
|
||||
//printf(" vmnAdd1 %s\n", n.GetHex().c_str());
|
||||
//LogPrintf(" vmnAdd1 %s\n", n.GetHex().c_str());
|
||||
|
||||
vmnAdditional += n;
|
||||
//printf(" vmnAdd2 %s\n", vmnAdditional.GetHex().c_str());
|
||||
//LogPrintf(" vmnAdd2 %s\n", vmnAdditional.GetHex().c_str());
|
||||
vmnAdditional <<= (mv1.votes*8) + (mv1.blockHeight % 64);
|
||||
//printf(" vmnAdd3 %s\n", vmnAdditional.GetHex().c_str());
|
||||
//LogPrintf(" vmnAdd3 %s\n", vmnAdditional.GetHex().c_str());
|
||||
}
|
||||
|
||||
hash = Hash9(BEGIN(nVersion), END(nNonce));
|
||||
@ -2222,7 +2222,7 @@ bool CBlock::ConnectBlock(CValidationState &state, CBlockIndex* pindex, CCoinsVi
|
||||
}
|
||||
int64 nTime = GetTimeMicros() - nStart;
|
||||
if (fBenchmark)
|
||||
printf("- Connect %u transactions: %.2fms (%.3fms/tx, %.3fms/txin)\n", (unsigned)vtx.size(), 0.001 * nTime, 0.001 * nTime / vtx.size(), nInputs <= 1 ? 0 : 0.001 * nTime / (nInputs-1));
|
||||
LogPrintf("- Connect %u transactions: %.2fms (%.3fms/tx, %.3fms/txin)\n", (unsigned)vtx.size(), 0.001 * nTime, 0.001 * nTime / vtx.size(), nInputs <= 1 ? 0 : 0.001 * nTime / (nInputs-1));
|
||||
|
||||
if (vtx[0].GetValueOut() > GetBlockValue(pindex->pprev->nBits, pindex->pprev->nHeight, nFees))
|
||||
return state.DoS(100, error("ConnectBlock() : coinbase pays too much (actual=%"PRI64d" vs limit=%"PRI64d")", vtx[0].GetValueOut(), GetBlockValue(pindex->pprev->nBits, pindex->pprev->nHeight, nFees)));
|
||||
@ -2231,7 +2231,7 @@ bool CBlock::ConnectBlock(CValidationState &state, CBlockIndex* pindex, CCoinsVi
|
||||
return state.DoS(100, false);
|
||||
int64 nTime2 = GetTimeMicros() - nStart;
|
||||
if (fBenchmark)
|
||||
printf("- Verify %u txins: %.2fms (%.3fms/txin)\n", nInputs - 1, 0.001 * nTime2, nInputs <= 1 ? 0 : 0.001 * nTime2 / (nInputs-1));
|
||||
LogPrintf("- Verify %u txins: %.2fms (%.3fms/txin)\n", nInputs - 1, 0.001 * nTime2, nInputs <= 1 ? 0 : 0.001 * nTime2 / (nInputs-1));
|
||||
|
||||
if (fJustCheck)
|
||||
return true;
|
||||
@ -2305,8 +2305,8 @@ bool SetBestChain(CValidationState &state, CBlockIndex* pindexNew)
|
||||
reverse(vConnect.begin(), vConnect.end());
|
||||
|
||||
if (vDisconnect.size() > 0) {
|
||||
printf("REORGANIZE: Disconnect %"PRIszu" blocks; %s..\n", vDisconnect.size(), pfork->GetBlockHash().ToString().c_str());
|
||||
printf("REORGANIZE: Connect %"PRIszu" blocks; ..%s\n", vConnect.size(), pindexNew->GetBlockHash().ToString().c_str());
|
||||
LogPrintf("REORGANIZE: Disconnect %"PRIszu" blocks; %s..\n", vDisconnect.size(), pfork->GetBlockHash().ToString().c_str());
|
||||
LogPrintf("REORGANIZE: Connect %"PRIszu" blocks; ..%s\n", vConnect.size(), pindexNew->GetBlockHash().ToString().c_str());
|
||||
}
|
||||
|
||||
// Disconnect shorter branch
|
||||
@ -2319,7 +2319,7 @@ bool SetBestChain(CValidationState &state, CBlockIndex* pindexNew)
|
||||
if (!block.DisconnectBlock(state, pindex, view))
|
||||
return error("SetBestBlock() : DisconnectBlock %s failed", pindex->GetBlockHash().ToString().c_str());
|
||||
if (fBenchmark)
|
||||
printf("- Disconnect: %.2fms\n", (GetTimeMicros() - nStart) * 0.001);
|
||||
LogPrintf("- Disconnect: %.2fms\n", (GetTimeMicros() - nStart) * 0.001);
|
||||
|
||||
// Queue memory transactions to resurrect.
|
||||
// We only do this for blocks after the last checkpoint (reorganisation before that
|
||||
@ -2344,7 +2344,7 @@ bool SetBestChain(CValidationState &state, CBlockIndex* pindexNew)
|
||||
return error("SetBestBlock() : ConnectBlock %s failed", pindex->GetBlockHash().ToString().c_str());
|
||||
}
|
||||
if (fBenchmark)
|
||||
printf("- Connect: %.2fms\n", (GetTimeMicros() - nStart) * 0.001);
|
||||
LogPrintf("- Connect: %.2fms\n", (GetTimeMicros() - nStart) * 0.001);
|
||||
|
||||
// Queue memory transactions to delete
|
||||
BOOST_FOREACH(const CTransaction& tx, block.vtx)
|
||||
@ -2357,7 +2357,7 @@ bool SetBestChain(CValidationState &state, CBlockIndex* pindexNew)
|
||||
assert(view.Flush());
|
||||
int64 nTime = GetTimeMicros() - nStart;
|
||||
if (fBenchmark)
|
||||
printf("- Flush %i transactions: %.2fms (%.4fms/tx)\n", nModified, 0.001 * nTime, 0.001 * nTime / nModified);
|
||||
LogPrintf("- Flush %i transactions: %.2fms (%.4fms/tx)\n", nModified, 0.001 * nTime, 0.001 * nTime / nModified);
|
||||
|
||||
// Make sure it's successfully written to disk before changing memory structure
|
||||
bool fIsInitialDownload = IsInitialBlockDownload();
|
||||
@ -2417,7 +2417,7 @@ bool SetBestChain(CValidationState &state, CBlockIndex* pindexNew)
|
||||
nBestChainWork = pindexNew->nChainWork;
|
||||
nTimeBestReceived = GetTime();
|
||||
nTransactionsUpdated++;
|
||||
printf("SetBestChain: new best=%s height=%d log2_work=%.8g tx=%lu date=%s progress=%f\n",
|
||||
LogPrintf("SetBestChain: new best=%s height=%d log2_work=%.8g tx=%lu date=%s progress=%f\n",
|
||||
hashBestChain.ToString().c_str(), nBestHeight, log(nBestChainWork.getdouble())/log(2.0), (unsigned long)pindexNew->nChainTx,
|
||||
DateTimeStrFormat("%Y-%m-%d %H:%M:%S", pindexBest->GetBlockTime()).c_str(),
|
||||
Checkpoints::GuessVerificationProgress(pindexBest));
|
||||
@ -2434,7 +2434,7 @@ bool SetBestChain(CValidationState &state, CBlockIndex* pindexNew)
|
||||
pindex = pindex->pprev;
|
||||
}
|
||||
if (nUpgraded > 0)
|
||||
printf("SetBestChain: %d of last 100 blocks above version %d\n", nUpgraded, CBlock::CURRENT_VERSION);
|
||||
LogPrintf("SetBestChain: %d of last 100 blocks above version %d\n", nUpgraded, CBlock::CURRENT_VERSION);
|
||||
if (nUpgraded > 100/2)
|
||||
// strMiscWarning is read by GetWarnings(), called by Qt and the JSON-RPC code to warn the user:
|
||||
strMiscWarning = _("Warning: This version is obsolete, upgrade required!");
|
||||
@ -2517,7 +2517,7 @@ bool FindBlockPos(CValidationState &state, CDiskBlockPos &pos, unsigned int nAdd
|
||||
}
|
||||
} else {
|
||||
while (infoLastBlockFile.nSize + nAddSize >= MAX_BLOCKFILE_SIZE) {
|
||||
printf("Leaving block file %i: %s\n", nLastBlockFile, infoLastBlockFile.ToString().c_str());
|
||||
LogPrintf("Leaving block file %i: %s\n", nLastBlockFile, infoLastBlockFile.ToString().c_str());
|
||||
FlushBlockFile(true);
|
||||
nLastBlockFile++;
|
||||
infoLastBlockFile.SetNull();
|
||||
@ -2538,7 +2538,7 @@ bool FindBlockPos(CValidationState &state, CDiskBlockPos &pos, unsigned int nAdd
|
||||
if (CheckDiskSpace(nNewChunks * BLOCKFILE_CHUNK_SIZE - pos.nPos)) {
|
||||
FILE *file = OpenBlockFile(pos);
|
||||
if (file) {
|
||||
printf("Pre-allocating up to position 0x%x in blk%05u.dat\n", nNewChunks * BLOCKFILE_CHUNK_SIZE, pos.nFile);
|
||||
LogPrintf("Pre-allocating up to position 0x%x in blk%05u.dat\n", nNewChunks * BLOCKFILE_CHUNK_SIZE, pos.nFile);
|
||||
AllocateFileRange(file, pos.nPos, nNewChunks * BLOCKFILE_CHUNK_SIZE - pos.nPos);
|
||||
fclose(file);
|
||||
}
|
||||
@ -2584,7 +2584,7 @@ bool FindUndoPos(CValidationState &state, int nFile, CDiskBlockPos &pos, unsigne
|
||||
if (CheckDiskSpace(nNewChunks * UNDOFILE_CHUNK_SIZE - pos.nPos)) {
|
||||
FILE *file = OpenUndoFile(pos);
|
||||
if (file) {
|
||||
printf("Pre-allocating up to position 0x%x in rev%05u.dat\n", nNewChunks * UNDOFILE_CHUNK_SIZE, pos.nFile);
|
||||
LogPrintf("Pre-allocating up to position 0x%x in rev%05u.dat\n", nNewChunks * UNDOFILE_CHUNK_SIZE, pos.nFile);
|
||||
AllocateFileRange(file, pos.nPos, nNewChunks * UNDOFILE_CHUNK_SIZE - pos.nPos);
|
||||
fclose(file);
|
||||
}
|
||||
@ -2659,7 +2659,7 @@ bool CBlock::CheckBlock(CValidationState &state, bool fCheckPOW, bool fCheckMerk
|
||||
|
||||
// Work back to the first block in the orphan chain
|
||||
if (mapBlockIndex.count(hashPrevBlock)){
|
||||
printf("CheckBlock() : loading prev block %s\n", hashPrevBlock.ToString().c_str());
|
||||
LogPrintf("CheckBlock() : loading prev block %s\n", hashPrevBlock.ToString().c_str());
|
||||
pindexPrev = mapBlockIndex[hashPrevBlock];
|
||||
if(!blockLast.ReadFromDisk(pindexPrev)){
|
||||
return error("CheckBlock() : Load previous block failed");
|
||||
@ -2675,12 +2675,12 @@ bool CBlock::CheckBlock(CValidationState &state, bool fCheckPOW, bool fCheckMerk
|
||||
if (pindexPrev != NULL && !fIsInitialDownload){
|
||||
{
|
||||
if(blockLast.GetHash() != pindexPrev->GetBlockHash()){
|
||||
printf ("CheckBlock() : blockLast.GetHash() != pindexPrev->GetBlockHash() : %s != %s\n", blockLast.GetHash().ToString().c_str(), pindexPrev->GetBlockHash().ToString().c_str());
|
||||
LogPrintf("CheckBlock() : blockLast.GetHash() != pindexPrev->GetBlockHash() : %s != %s\n", blockLast.GetHash().ToString().c_str(), pindexPrev->GetBlockHash().ToString().c_str());
|
||||
if(EnforceMasternodePayments) return state.DoS(100, error("CheckBlock() : blockLast.GetHash() != pindexPrev->GetBlockHash()"));
|
||||
}
|
||||
|
||||
printf ("CheckBlock() : nHeight : %d\n", pindexPrev->nHeight);
|
||||
printf ("CheckBlock() : pindexPrev->GetBlockHash() : %s\n", pindexPrev->GetBlockHash().ToString().c_str());
|
||||
LogPrintf("CheckBlock() : nHeight : %d\n", pindexPrev->nHeight);
|
||||
LogPrintf("CheckBlock() : pindexPrev->GetBlockHash() : %s\n", pindexPrev->GetBlockHash().ToString().c_str());
|
||||
|
||||
votingRecordsBlockPrev = blockLast.vmn.size();
|
||||
BOOST_FOREACH(CMasterNodeVote mv1, blockLast.vmn){
|
||||
@ -2693,15 +2693,15 @@ bool CBlock::CheckBlock(CValidationState &state, bool fCheckPOW, bool fCheckMerk
|
||||
if(vtx[0].vout[i].nValue == masternodePaymentAmount && mv1.GetPubKey() == vtx[0].vout[i].scriptPubKey) {
|
||||
foundMasterNodePayment++;
|
||||
} else if(mv1.GetPubKey() == vtx[0].vout[i].scriptPubKey) {
|
||||
printf(" BAD MASTERNODE PAYMENT DETECTED: %"PRI64u"\n", vtx[0].vout[i].nValue);
|
||||
LogPrintf(" BAD MASTERNODE PAYMENT DETECTED: %"PRI64u"\n", vtx[0].vout[i].nValue);
|
||||
}
|
||||
} else {
|
||||
BOOST_FOREACH(CMasterNodeVote mv2, vmn){
|
||||
if((mv1.blockHeight == mv2.blockHeight && mv1.GetPubKey() == mv2.GetPubKey())){
|
||||
matchingVoteRecords++;
|
||||
if(mv1.GetVotes() != mv2.GetVotes() && mv1.GetVotes()+1 != mv2.GetVotes()) {
|
||||
printf(" BAD VOTE DETECTED: %"PRI64u" %s\n", mv1.blockHeight, mv1.GetPubKey().ToString().c_str());
|
||||
printf(" -- %d %d\n", mv1.GetVotes(), mv2.GetVotes());
|
||||
LogPrintf(" BAD VOTE DETECTED: %"PRI64u" %s\n", mv1.blockHeight, mv1.GetPubKey().ToString().c_str());
|
||||
LogPrintf(" -- %d %d\n", mv1.GetVotes(), mv2.GetVotes());
|
||||
badVote++;
|
||||
}
|
||||
}
|
||||
@ -2709,11 +2709,11 @@ bool CBlock::CheckBlock(CValidationState &state, bool fCheckPOW, bool fCheckMerk
|
||||
}
|
||||
}
|
||||
|
||||
printf ("CheckBlock(): votingRecordsBlockPrev %d\n", votingRecordsBlockPrev);
|
||||
printf ("CheckBlock(): matchingVoteRecords %d\n", matchingVoteRecords);
|
||||
printf ("CheckBlock(): badVote %d\n", badVote);\
|
||||
printf ("CheckBlock(): foundMasterNodePayment %d\n", foundMasterNodePayment);
|
||||
printf ("CheckBlock(): removedMasterNodePayments %d\n", removedMasterNodePayments);
|
||||
LogPrintf("CheckBlock(): votingRecordsBlockPrev %d\n", votingRecordsBlockPrev);
|
||||
LogPrintf("CheckBlock(): matchingVoteRecords %d\n", matchingVoteRecords);
|
||||
LogPrintf("CheckBlock(): badVote %d\n", badVote);\
|
||||
LogPrintf("CheckBlock(): foundMasterNodePayment %d\n", foundMasterNodePayment);
|
||||
LogPrintf("CheckBlock(): removedMasterNodePayments %d\n", removedMasterNodePayments);
|
||||
|
||||
|
||||
//find new votes, must be for this block height
|
||||
@ -2730,7 +2730,7 @@ bool CBlock::CheckBlock(CValidationState &state, bool fCheckPOW, bool fCheckMerk
|
||||
|
||||
std::string votes = boost::lexical_cast<std::string>(mv2.votes);
|
||||
|
||||
printf("CheckBlock(): %s %s %s\n", blockHeight.c_str(), address2.ToString().c_str(), votes.c_str());
|
||||
LogPrintf("CheckBlock(): %s %s %s\n", blockHeight.c_str(), address2.ToString().c_str(), votes.c_str());
|
||||
}
|
||||
|
||||
if(mv2.GetPubKey().size() != 25){
|
||||
@ -2750,7 +2750,7 @@ bool CBlock::CheckBlock(CValidationState &state, bool fCheckPOW, bool fCheckMerk
|
||||
}
|
||||
|
||||
if(!found){
|
||||
printf("CheckBlock() : pubkey wrong size");
|
||||
LogPrintf("CheckBlock() : pubkey wrong size");
|
||||
if(EnforceMasternodePayments) return state.DoS(100, error("CheckBlock() : Vote not found in previous block"));
|
||||
}
|
||||
}
|
||||
@ -2758,17 +2758,17 @@ bool CBlock::CheckBlock(CValidationState &state, bool fCheckPOW, bool fCheckMerk
|
||||
|
||||
|
||||
if(badVote!=0){
|
||||
printf("CheckBlock() : Bad vote detected");
|
||||
LogPrintf("CheckBlock() : Bad vote detected");
|
||||
if(EnforceMasternodePayments) return state.DoS(100, error("CheckBlock() : Bad vote detected"));
|
||||
}
|
||||
|
||||
if(matchingVoteRecords+foundMasterNodePayment+removedMasterNodePayments!=votingRecordsBlockPrev) {
|
||||
printf("CheckBlock() : Missing masternode votes");
|
||||
LogPrintf("CheckBlock() : Missing masternode votes");
|
||||
if(EnforceMasternodePayments) return state.DoS(100, error("CheckBlock() : Missing masternode votes"));
|
||||
}
|
||||
|
||||
if(matchingVoteRecords+foundMasterNodePayment>MASTERNODE_PAYMENTS_EXPIRATION){
|
||||
printf("CheckBlock() : Too many vote records found");
|
||||
LogPrintf("CheckBlock() : Too many vote records found");
|
||||
if(EnforceMasternodePayments) return state.DoS(100, error("CheckBlock() : Too many vote records found"));
|
||||
}
|
||||
}
|
||||
@ -2976,7 +2976,7 @@ bool ProcessBlock(CValidationState &state, CNode* pfrom, CBlock* pblock, CDiskBl
|
||||
// If we don't already have its previous block, shunt it off to holding area until we get it
|
||||
if (pblock->hashPrevBlock != 0 && !mapBlockIndex.count(pblock->hashPrevBlock))
|
||||
{
|
||||
printf("ProcessBlock: ORPHAN BLOCK, prev=%s\n", pblock->hashPrevBlock.ToString().c_str());
|
||||
LogPrintf("ProcessBlock: ORPHAN BLOCK, prev=%s\n", pblock->hashPrevBlock.ToString().c_str());
|
||||
|
||||
// Accept orphans as long as there is a node to request its parents from
|
||||
if (pfrom) {
|
||||
@ -2986,7 +2986,7 @@ bool ProcessBlock(CValidationState &state, CNode* pfrom, CBlock* pblock, CDiskBl
|
||||
|
||||
// Ask this guy to fill in what we're missing
|
||||
if (pfrom->PushGetBlocks(pindexBest, GetOrphanRoot(pblock2)))
|
||||
printf("send fill-in getblocks for %s peer=%d\n", hash.ToString().c_str(), pfrom->id);
|
||||
LogPrintf("send fill-in getblocks for %s peer=%d\n", hash.ToString().c_str(), pfrom->id);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -3190,7 +3190,7 @@ uint256 CPartialMerkleTree::ExtractMatches(std::vector<uint256> &vMatch) {
|
||||
|
||||
bool AbortNode(const std::string &strMessage) {
|
||||
strMiscWarning = strMessage;
|
||||
printf("*** %s\n", strMessage.c_str());
|
||||
LogPrintf("*** %s\n", strMessage.c_str());
|
||||
uiInterface.ThreadSafeMessageBox(strMessage, "", CClientUIInterface::MSG_ERROR);
|
||||
StartShutdown();
|
||||
return false;
|
||||
@ -3221,12 +3221,12 @@ FILE* OpenDiskFile(const CDiskBlockPos &pos, const char *prefix, bool fReadOnly)
|
||||
if (!file && !fReadOnly)
|
||||
file = fopen(path.string().c_str(), "wb+");
|
||||
if (!file) {
|
||||
printf("Unable to open file %s\n", path.string().c_str());
|
||||
LogPrintf("Unable to open file %s\n", path.string().c_str());
|
||||
return NULL;
|
||||
}
|
||||
if (pos.nPos) {
|
||||
if (fseek(file, pos.nPos, SEEK_SET)) {
|
||||
printf("Unable to seek to position %u of %s\n", pos.nPos, path.string().c_str());
|
||||
LogPrintf("Unable to seek to position %u of %s\n", pos.nPos, path.string().c_str());
|
||||
fclose(file);
|
||||
return NULL;
|
||||
}
|
||||
@ -3289,14 +3289,14 @@ bool static LoadBlockIndexDB()
|
||||
|
||||
// Load block file info
|
||||
pblocktree->ReadLastBlockFile(nLastBlockFile);
|
||||
printf("LoadBlockIndexDB(): last block file = %i\n", nLastBlockFile);
|
||||
LogPrintf("LoadBlockIndexDB(): last block file = %i\n", nLastBlockFile);
|
||||
if (pblocktree->ReadBlockFileInfo(nLastBlockFile, infoLastBlockFile))
|
||||
printf("LoadBlockIndexDB(): last block file info: %s\n", infoLastBlockFile.ToString().c_str());
|
||||
LogPrintf("LoadBlockIndexDB(): last block file info: %s\n", infoLastBlockFile.ToString().c_str());
|
||||
|
||||
if (!pblocktree->ReadSyncCheckpoint(hashSyncCheckpoint))
|
||||
printf("LoadBlockIndexDB(): synchronized checkpoint not read\n");
|
||||
LogPrintf("LoadBlockIndexDB(): synchronized checkpoint not read\n");
|
||||
else
|
||||
printf("LoadBlockIndexDB(): synchronized checkpoint %s\n", hashSyncCheckpoint.ToString().c_str());
|
||||
LogPrintf("LoadBlockIndexDB(): synchronized checkpoint %s\n", hashSyncCheckpoint.ToString().c_str());
|
||||
|
||||
// Load nBestInvalidWork, OK if it doesn't exist
|
||||
CBigNum bnBestInvalidWork;
|
||||
@ -3310,7 +3310,7 @@ bool static LoadBlockIndexDB()
|
||||
|
||||
// Check whether we have a transaction index
|
||||
pblocktree->ReadFlag("txindex", fTxIndex);
|
||||
printf("LoadBlockIndexDB(): transaction index %s\n", fTxIndex ? "enabled" : "disabled");
|
||||
LogPrintf("LoadBlockIndexDB(): transaction index %s\n", fTxIndex ? "enabled" : "disabled");
|
||||
|
||||
// Load hashBestChain pointer to end of best chain
|
||||
pindexBest = pcoinsTip->GetBestBlock();
|
||||
@ -3327,7 +3327,7 @@ bool static LoadBlockIndexDB()
|
||||
pindexPrev->pnext = pindex;
|
||||
pindex = pindexPrev;
|
||||
}
|
||||
printf("LoadBlockIndexDB(): hashBestChain=%s height=%d date=%s\n",
|
||||
LogPrintf("LoadBlockIndexDB(): hashBestChain=%s height=%d date=%s\n",
|
||||
hashBestChain.ToString().c_str(), nBestHeight,
|
||||
DateTimeStrFormat("%Y-%m-%d %H:%M:%S", pindexBest->GetBlockTime()).c_str());
|
||||
|
||||
@ -3345,7 +3345,7 @@ bool VerifyDB(int nCheckLevel, int nCheckDepth)
|
||||
if (nCheckDepth > nBestHeight)
|
||||
nCheckDepth = nBestHeight;
|
||||
nCheckLevel = std::max(0, std::min(4, nCheckLevel));
|
||||
printf("Verifying last %i blocks at level %i\n", nCheckDepth, nCheckLevel);
|
||||
LogPrintf("Verifying last %i blocks at level %i\n", nCheckDepth, nCheckLevel);
|
||||
CCoinsViewCache coins(*pcoinsTip, true);
|
||||
CBlockIndex* pindexState = pindexBest;
|
||||
CBlockIndex* pindexFailure = NULL;
|
||||
@ -3402,7 +3402,7 @@ bool VerifyDB(int nCheckLevel, int nCheckDepth)
|
||||
}
|
||||
}
|
||||
|
||||
printf("No coin database inconsistencies in last %i blocks (%i transactions)\n", pindexBest->nHeight - pindexState->nHeight, nGoodTransactions);
|
||||
LogPrintf("No coin database inconsistencies in last %i blocks (%i transactions)\n", pindexBest->nHeight - pindexState->nHeight, nGoodTransactions);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -3448,7 +3448,7 @@ bool InitBlockIndex() {
|
||||
// Use the provided setting for -txindex in the new database
|
||||
fTxIndex = GetBoolArg("-txindex", false);
|
||||
pblocktree->WriteFlag("txindex", fTxIndex);
|
||||
printf("Initializing databases...\n");
|
||||
LogPrintf("Initializing databases...\n");
|
||||
|
||||
// Only add the genesis block if not reindexing (in which case we reuse the one already on disk)
|
||||
if (!fReindex) {
|
||||
@ -3484,9 +3484,9 @@ bool InitBlockIndex() {
|
||||
|
||||
//// debug print
|
||||
uint256 hash = block.GetHash();
|
||||
printf("%s\n", hash.ToString().c_str());
|
||||
printf("%s\n", hashGenesisBlock.ToString().c_str());
|
||||
printf("%s\n", block.hashMerkleRoot.ToString().c_str());
|
||||
LogPrintf("%s\n", hash.ToString().c_str());
|
||||
LogPrintf("%s\n", hashGenesisBlock.ToString().c_str());
|
||||
LogPrintf("%s\n", block.hashMerkleRoot.ToString().c_str());
|
||||
assert(block.hashMerkleRoot == uint256("0xe0028eb9648db56b1ac77cf090b99048a8007e2bb64b68f092c03c7f56a662c7"));
|
||||
block.print();
|
||||
assert(hash == hashGenesisBlock);
|
||||
@ -3545,25 +3545,25 @@ void PrintBlockTree()
|
||||
if (nCol > nPrevCol)
|
||||
{
|
||||
for (int i = 0; i < nCol-1; i++)
|
||||
printf("| ");
|
||||
printf("|\\\n");
|
||||
LogPrintf("| ");
|
||||
LogPrintf("|\\\n");
|
||||
}
|
||||
else if (nCol < nPrevCol)
|
||||
{
|
||||
for (int i = 0; i < nCol; i++)
|
||||
printf("| ");
|
||||
printf("|\n");
|
||||
LogPrintf("| ");
|
||||
LogPrintf("|\n");
|
||||
}
|
||||
nPrevCol = nCol;
|
||||
|
||||
// print columns
|
||||
for (int i = 0; i < nCol; i++)
|
||||
printf("| ");
|
||||
LogPrintf("| ");
|
||||
|
||||
// print item
|
||||
CBlock block;
|
||||
block.ReadFromDisk(pindex);
|
||||
printf("%d (blk%05u.dat:0x%x) %s tx %"PRIszu"",
|
||||
LogPrintf("%d (blk%05u.dat:0x%x) %s tx %"PRIszu"",
|
||||
pindex->nHeight,
|
||||
pindex->GetBlockPos().nFile, pindex->GetBlockPos().nPos,
|
||||
DateTimeStrFormat("%Y-%m-%d %H:%M:%S", block.GetBlockTime()).c_str(),
|
||||
@ -3651,7 +3651,7 @@ bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos *dbp)
|
||||
break;
|
||||
}
|
||||
} catch (std::exception &e) {
|
||||
printf("%s() : Deserialize or I/O error caught during load\n", __PRETTY_FUNCTION__);
|
||||
LogPrintf("%s() : Deserialize or I/O error caught during load\n", __PRETTY_FUNCTION__);
|
||||
}
|
||||
}
|
||||
fclose(fileIn);
|
||||
@ -3659,7 +3659,7 @@ bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos *dbp)
|
||||
AbortNode(_("Error: system error: ") + e.what());
|
||||
}
|
||||
if (nLoaded > 0)
|
||||
printf("Loaded %i blocks from external file in %"PRI64d"ms\n", nLoaded, GetTimeMillis() - nStart);
|
||||
LogPrintf("Loaded %i blocks from external file in %"PRI64d"ms\n", nLoaded, GetTimeMillis() - nStart);
|
||||
return nLoaded > 0;
|
||||
}
|
||||
|
||||
@ -3815,7 +3815,7 @@ void static ProcessGetData(CNode* pfrom)
|
||||
if (pcheckpoint && nHeight < pcheckpoint->nHeight) {
|
||||
if (!((*mi).second)->IsInMainChain())
|
||||
{
|
||||
printf("ProcessGetData(): ignoring request for old block that isn't in the main chain\n");
|
||||
LogPrintf("ProcessGetData(): ignoring request for old block that isn't in the main chain\n");
|
||||
send = false;
|
||||
}
|
||||
}
|
||||
@ -3918,10 +3918,10 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
||||
{
|
||||
RandAddSeedPerfmon();
|
||||
if (fDebug)
|
||||
printf("received: %s (%"PRIszu" bytes)\n", strCommand.c_str(), vRecv.size());
|
||||
LogPrintf("received: %s (%"PRIszu" bytes)\n", strCommand.c_str(), vRecv.size());
|
||||
if (mapArgs.count("-dropmessagestest") && GetRand(atoi(mapArgs["-dropmessagestest"])) == 0)
|
||||
{
|
||||
printf("dropmessagestest DROPPING RECV MESSAGE\n");
|
||||
LogPrintf("dropmessagestest DROPPING RECV MESSAGE\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -3935,7 +3935,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
||||
{
|
||||
string strMessageStart((const char *)pchMessageStart);
|
||||
vector<unsigned char> vchMessageStart(strMessageStart.begin(), strMessageStart.end());
|
||||
printf("ProcessMessages : AdjustedTime=%"PRI64d" MessageStart=%s\n", GetAdjustedTime(), HexStr(vchMessageStart).c_str());
|
||||
LogPrintf("ProcessMessages : AdjustedTime=%"PRI64d" MessageStart=%s\n", GetAdjustedTime(), HexStr(vchMessageStart).c_str());
|
||||
nTimeLastPrintMessageStart = GetAdjustedTime();
|
||||
}
|
||||
|
||||
@ -3957,7 +3957,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
||||
if (pfrom->nVersion < MIN_PEER_PROTO_VERSION)
|
||||
{
|
||||
// disconnect from peers older than this proto version
|
||||
printf("partner %s using obsolete version %i; disconnecting\n", pfrom->addr.ToString().c_str(), pfrom->nVersion);
|
||||
LogPrintf("partner %s using obsolete version %i; disconnecting\n", pfrom->addr.ToString().c_str(), pfrom->nVersion);
|
||||
pfrom->fDisconnect = true;
|
||||
return false;
|
||||
}
|
||||
@ -3986,7 +3986,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
||||
// Disconnect if we connected to ourself
|
||||
if (nNonce == nLocalHostNonce && nNonce > 1)
|
||||
{
|
||||
printf("connected to self at %s, disconnecting\n", pfrom->addr.ToString().c_str());
|
||||
LogPrintf("connected to self at %s, disconnecting\n", pfrom->addr.ToString().c_str());
|
||||
pfrom->fDisconnect = true;
|
||||
return true;
|
||||
}
|
||||
@ -4055,7 +4055,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
||||
|
||||
pfrom->fSuccessfullyConnected = true;
|
||||
|
||||
printf("receive version message: %s: version %d, blocks=%d, us=%s, them=%s, peer=%d\n", pfrom->cleanSubVer.c_str(), pfrom->nVersion, pfrom->nStartingHeight, addrMe.ToString().c_str(), addrFrom.ToString().c_str(), pfrom->id);
|
||||
LogPrintf("receive version message: %s: version %d, blocks=%d, us=%s, them=%s, peer=%d\n", pfrom->cleanSubVer.c_str(), pfrom->nVersion, pfrom->nStartingHeight, addrMe.ToString().c_str(), addrFrom.ToString().c_str(), pfrom->id);
|
||||
|
||||
cPeerBlockCounts.input(pfrom->nStartingHeight);
|
||||
|
||||
@ -4080,7 +4080,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
||||
else if (strCommand == "misbehave") {
|
||||
int howmuch;
|
||||
vRecv >> howmuch;
|
||||
printf("peer=%d says we are misbehaving %d\n", pfrom->id, howmuch);
|
||||
LogPrintf("peer=%d says we are misbehaving %d\n", pfrom->id, howmuch);
|
||||
}
|
||||
|
||||
else if (strCommand == "dseg") { //DarkSend Election Get
|
||||
@ -4092,7 +4092,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
||||
int i = 0;
|
||||
|
||||
BOOST_FOREACH(CMasterNode mn, darkSendMasterNodes) {
|
||||
printf("Sending master node entry - %s \n", mn.addr.ToString().c_str());
|
||||
LogPrintf("Sending master node entry - %s \n", mn.addr.ToString().c_str());
|
||||
mn.Check();
|
||||
if(mn.IsEnabled()) {
|
||||
pfrom->PushMessage("dsee", mn.vin, mn.addr, mn.sig, mn.now, mn.pubkey, mn.pubkey2, count, i, mn.lastTimeSeen);
|
||||
@ -4125,7 +4125,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
||||
pubkeyScript.SetDestination(pubkey.GetID());
|
||||
|
||||
if(pubkeyScript.size() != 25) {
|
||||
printf("dsee - pubkey the wrong size\n");
|
||||
LogPrintf("dsee - pubkey the wrong size\n");
|
||||
pfrom->Misbehaving(100);
|
||||
return false;
|
||||
}
|
||||
@ -4136,24 +4136,24 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
||||
pubkeyScript2.SetDestination(pubkey2.GetID());
|
||||
|
||||
if(pubkeyScript2.size() != 25) {
|
||||
printf("dsee - pubkey the wrong size\n");
|
||||
LogPrintf("dsee - pubkey the wrong size\n");
|
||||
pfrom->Misbehaving(100);
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string errorMessage = "";
|
||||
if(!darkSendSigner.VerifyMessage(pubkey, vchSig, strMessage, errorMessage)){
|
||||
printf("dsee - Got bad masternode address signature\n");
|
||||
LogPrintf("dsee - Got bad masternode address signature\n");
|
||||
pfrom->Misbehaving(100);
|
||||
return false;
|
||||
}
|
||||
|
||||
if((fTestNet && addr.GetPort() != 19999) || (!fTestNet && addr.GetPort() != 9999)) return true;
|
||||
|
||||
//printf("Searching existing masternodes : %s - %s\n", addr.ToString().c_str(), vin.ToString().c_str());
|
||||
//LogPrintf("Searching existing masternodes : %s - %s\n", addr.ToString().c_str(), vin.ToString().c_str());
|
||||
|
||||
BOOST_FOREACH(CMasterNode& mn, darkSendMasterNodes) {
|
||||
//printf(" -- %s\n", mn.vin.ToString().c_str());
|
||||
//LogPrintf(" -- %s\n", mn.vin.ToString().c_str());
|
||||
|
||||
if(mn.vin == vin) {
|
||||
if(!mn.UpdatedWithin(MASTERNODE_MIN_MICROSECONDS)){
|
||||
@ -4167,7 +4167,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
||||
}
|
||||
}
|
||||
|
||||
printf("dsee - Got NEW masternode entry %s\n", addr.ToString().c_str());
|
||||
LogPrintf("dsee - Got NEW masternode entry %s\n", addr.ToString().c_str());
|
||||
|
||||
CValidationState state;
|
||||
CTransaction tx = CTransaction();
|
||||
@ -4175,10 +4175,10 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
||||
tx.vin.push_back(vin);
|
||||
tx.vout.push_back(vout);
|
||||
if(tx.AcceptableInputs(state, true)){
|
||||
printf("dsee - Accepted masternode entry %i %i\n", count, current);
|
||||
LogPrintf("dsee - Accepted masternode entry %i %i\n", count, current);
|
||||
|
||||
if(GetInputAge(vin) < MASTERNODE_MIN_CONFIRMATIONS){
|
||||
printf("dsee - Input must have least %d confirmations\n", MASTERNODE_MIN_CONFIRMATIONS);
|
||||
LogPrintf("dsee - Input must have least %d confirmations\n", MASTERNODE_MIN_CONFIRMATIONS);
|
||||
pfrom->Misbehaving(20);
|
||||
return false;
|
||||
}
|
||||
@ -4193,7 +4193,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
||||
RelayDarkSendElectionEntry(vin, addr, vchSig, sigTime, pubkey, pubkey2, count, current, lastUpdated);
|
||||
|
||||
} else {
|
||||
printf("dsee - Rejected masternode entry\n");
|
||||
LogPrintf("dsee - Rejected masternode entry\n");
|
||||
// if caught up on blocks, then do this:
|
||||
//pfrom->Misbehaving(20);
|
||||
}
|
||||
@ -4215,18 +4215,18 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
||||
CBlockIndex* pindexPrev = pindexBest;
|
||||
|
||||
if (sigTime/1000000 > GetAdjustedTime() + 15 * 60) {
|
||||
printf("dseep: Signature rejected, too far into the future");
|
||||
LogPrintf("dseep: Signature rejected, too far into the future");
|
||||
//pfrom->Misbehaving(20);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (sigTime/1000000 <= pindexPrev->GetBlockTime() - 15 * 60) {
|
||||
printf("dseep: Signature rejected, too far into the past");
|
||||
LogPrintf("dseep: Signature rejected, too far into the past");
|
||||
//pfrom->Misbehaving(20);
|
||||
return false;
|
||||
}
|
||||
|
||||
//printf("Searching existing masternodes : %s - %s\n", addr.ToString().c_str(), vin.ToString().c_str());
|
||||
//LogPrintf("Searching existing masternodes : %s - %s\n", addr.ToString().c_str(), vin.ToString().c_str());
|
||||
|
||||
BOOST_FOREACH(CMasterNode& mn, darkSendMasterNodes) {
|
||||
|
||||
@ -4235,7 +4235,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
||||
|
||||
std::string errorMessage = "";
|
||||
if(!darkSendSigner.VerifyMessage(mn.pubkey2, vchSig, strMessage, errorMessage)){
|
||||
printf("Got bad masternode address signature\n");
|
||||
LogPrintf("Got bad masternode address signature\n");
|
||||
//pfrom->Misbehaving(20);
|
||||
return false;
|
||||
}
|
||||
@ -4319,7 +4319,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
||||
if (vAddr.size() < 1000)
|
||||
pfrom->fGetAddr = false;
|
||||
if (pfrom->fOneShot) {
|
||||
printf("OneShot. Disconnecting\n");
|
||||
LogPrintf("OneShot. Disconnecting\n");
|
||||
pfrom->fDisconnect = true;
|
||||
}
|
||||
}
|
||||
@ -4352,22 +4352,22 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
||||
|
||||
bool fAlreadyHave = AlreadyHave(inv);
|
||||
if (fDebug)
|
||||
printf(" got inventory: %s %s\n", inv.ToString().c_str(), fAlreadyHave ? "have" : "new");
|
||||
LogPrintf(" got inventory: %s %s\n", inv.ToString().c_str(), fAlreadyHave ? "have" : "new");
|
||||
|
||||
if (!fAlreadyHave) {
|
||||
if (!fImporting && !fReindex)
|
||||
pfrom->AskFor(inv);
|
||||
} else if (inv.type == MSG_BLOCK && mapOrphanBlocks.count(inv.hash)) {
|
||||
if (pfrom->PushGetBlocks(pindexBest, GetOrphanRoot(mapOrphanBlocks[inv.hash])))
|
||||
printf("send getblocks for %s peer=%d\n", inv.hash.ToString().c_str(), pfrom->id);
|
||||
LogPrintf("send getblocks for %s peer=%d\n", inv.hash.ToString().c_str(), pfrom->id);
|
||||
} else if (nInv == nLastBlock) {
|
||||
// In case we are on a very long side-chain, it is possible that we already have
|
||||
// the last block in an inv bundle sent in response to getblocks. Try to detect
|
||||
// this situation and push another getblocks to continue.
|
||||
if (pfrom->PushGetBlocks(mapBlockIndex[inv.hash], uint256(0)))
|
||||
printf("send last getblocks for %s peer=%d\n", inv.hash.ToString().c_str(), pfrom->id);
|
||||
LogPrintf("send last getblocks for %s peer=%d\n", inv.hash.ToString().c_str(), pfrom->id);
|
||||
if (fDebug)
|
||||
printf("force request: %s\n", inv.ToString().c_str());
|
||||
LogPrintf("force request: %s\n", inv.ToString().c_str());
|
||||
}
|
||||
|
||||
// Track requests for our stuff
|
||||
@ -4387,10 +4387,10 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
||||
}
|
||||
|
||||
if (fDebugNet || (vInv.size() != 1))
|
||||
printf("received getdata (%"PRIszu" invsz) peer=%d\n", vInv.size(), pfrom->id);
|
||||
LogPrintf("received getdata (%"PRIszu" invsz) peer=%d\n", vInv.size(), pfrom->id);
|
||||
|
||||
if ((fDebugNet && vInv.size() > 0) || (vInv.size() == 1))
|
||||
printf("received getdata for: %s peer=%d\n", vInv[0].ToString().c_str(), pfrom->id);
|
||||
LogPrintf("received getdata for: %s peer=%d\n", vInv[0].ToString().c_str(), pfrom->id);
|
||||
|
||||
pfrom->vRecvGetData.insert(pfrom->vRecvGetData.end(), vInv.begin(), vInv.end());
|
||||
ProcessGetData(pfrom);
|
||||
@ -4410,12 +4410,12 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
||||
if (pindex)
|
||||
pindex = pindex->pnext;
|
||||
int nLimit = 500;
|
||||
printf("getblocks %d to %s limit %d peer=%d\n", (pindex ? pindex->nHeight : -1), hashStop==uint256(0) ? "0" : hashStop.ToString().c_str(), nLimit, pfrom->id);
|
||||
LogPrintf("getblocks %d to %s limit %d peer=%d\n", (pindex ? pindex->nHeight : -1), hashStop==uint256(0) ? "0" : hashStop.ToString().c_str(), nLimit, pfrom->id);
|
||||
for (; pindex; pindex = pindex->pnext)
|
||||
{
|
||||
if (pindex->GetBlockHash() == hashStop)
|
||||
{
|
||||
printf(" getblocks stopping at %d %s\n", pindex->nHeight, pindex->GetBlockHash().ToString().c_str());
|
||||
LogPrintf(" getblocks stopping at %d %s\n", pindex->nHeight, pindex->GetBlockHash().ToString().c_str());
|
||||
break;
|
||||
}
|
||||
pfrom->PushInventory(CInv(MSG_BLOCK, pindex->GetBlockHash()));
|
||||
@ -4423,7 +4423,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
||||
{
|
||||
// When this block is requested, we'll send an inv that'll make them
|
||||
// getblocks the next batch of inventory.
|
||||
printf(" getblocks stopping at limit %d %s\n", pindex->nHeight, pindex->GetBlockHash().ToString().c_str());
|
||||
LogPrintf(" getblocks stopping at limit %d %s\n", pindex->nHeight, pindex->GetBlockHash().ToString().c_str());
|
||||
pfrom->hashContinue = pindex->GetBlockHash();
|
||||
break;
|
||||
}
|
||||
@ -4457,7 +4457,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
||||
// we must use CBlocks, as CBlockHeaders won't include the 0x00 nTx count at the end
|
||||
vector<CBlock> vHeaders;
|
||||
int nLimit = 2000;
|
||||
printf("getheaders %d to %s\n", (pindex ? pindex->nHeight : -1), hashStop.ToString().c_str());
|
||||
LogPrintf("getheaders %d to %s\n", (pindex ? pindex->nHeight : -1), hashStop.ToString().c_str());
|
||||
for (; pindex; pindex = pindex->pnext)
|
||||
{
|
||||
vHeaders.push_back(pindex->GetBlockHeader());
|
||||
@ -4488,7 +4488,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
||||
vWorkQueue.push_back(inv.hash);
|
||||
vEraseQueue.push_back(inv.hash);
|
||||
|
||||
printf("AcceptToMemoryPool: %s %s : accepted %s (poolsz %"PRIszu")\n",
|
||||
LogPrintf("AcceptToMemoryPool: %s %s : accepted %s (poolsz %"PRIszu")\n",
|
||||
pfrom->addr.ToString().c_str(), pfrom->cleanSubVer.c_str(),
|
||||
tx.GetHash().ToString().c_str(),
|
||||
mempool.mapTx.size());
|
||||
@ -4511,7 +4511,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
||||
|
||||
if (tx.AcceptToMemoryPool(stateDummy, true, true, &fMissingInputs2))
|
||||
{
|
||||
printf(" accepted orphan tx %s\n", orphanHash.ToString().c_str());
|
||||
LogPrintf(" accepted orphan tx %s\n", orphanHash.ToString().c_str());
|
||||
RelayTransaction(orphanTx, orphanHash);
|
||||
mapAlreadyAskedFor.erase(CInv(MSG_TX, orphanHash));
|
||||
vWorkQueue.push_back(orphanHash);
|
||||
@ -4521,7 +4521,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
||||
{
|
||||
// invalid or too-little-fee orphan
|
||||
vEraseQueue.push_back(orphanHash);
|
||||
printf(" removed orphan tx %s\n", orphanHash.ToString().c_str());
|
||||
LogPrintf(" removed orphan tx %s\n", orphanHash.ToString().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -4536,12 +4536,12 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
||||
// DoS prevention: do not allow mapOrphanTransactions to grow unbounded
|
||||
unsigned int nEvicted = LimitOrphanTxSize(MAX_ORPHAN_TRANSACTIONS);
|
||||
if (nEvicted > 0)
|
||||
printf("mapOrphan overflow, removed %u tx\n", nEvicted);
|
||||
LogPrintf("mapOrphan overflow, removed %u tx\n", nEvicted);
|
||||
}
|
||||
int nDoS = 0;
|
||||
if (state.IsInvalid(nDoS))
|
||||
{
|
||||
printf("%s from %s %s was not accepted into the memory pool\n", tx.GetHash().ToString().c_str(),
|
||||
LogPrintf("%s from %s %s was not accepted into the memory pool\n", tx.GetHash().ToString().c_str(),
|
||||
pfrom->addr.ToString().c_str(), pfrom->cleanSubVer.c_str());
|
||||
if (nDoS > 0)
|
||||
pfrom->Misbehaving(nDoS);
|
||||
@ -4554,7 +4554,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
||||
CBlock block;
|
||||
vRecv >> block;
|
||||
|
||||
printf("received block %s peer=%d\n", block.GetHash().ToString().c_str(), pfrom->id);
|
||||
LogPrintf("received block %s peer=%d\n", block.GetHash().ToString().c_str(), pfrom->id);
|
||||
// block.print();
|
||||
|
||||
CInv inv(MSG_BLOCK, block.GetHash());
|
||||
@ -4671,7 +4671,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
||||
{
|
||||
// Relay
|
||||
pfrom->hashCheckpointKnown = checkpoint.hashCheckpoint;
|
||||
printf("!!! ENFORCING PAYMENTS %"PRI64u"\n", checkpoint.enforcingPaymentsTime);
|
||||
LogPrintf("!!! ENFORCING PAYMENTS %"PRI64u"\n", checkpoint.enforcingPaymentsTime);
|
||||
enforceMasternodePaymentsTime = checkpoint.enforcingPaymentsTime;
|
||||
|
||||
LOCK(cs_vNodes);
|
||||
@ -4747,7 +4747,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
||||
bool ProcessMessages(CNode* pfrom)
|
||||
{
|
||||
//if (fDebug)
|
||||
// printf("ProcessMessages(%zu messages)\n", pfrom->vRecvMsg.size());
|
||||
// LogPrintf("ProcessMessages(%zu messages)\n", pfrom->vRecvMsg.size());
|
||||
|
||||
//
|
||||
// Message format
|
||||
@ -4778,7 +4778,7 @@ bool ProcessMessages(CNode* pfrom)
|
||||
CNetMessage& msg = *it;
|
||||
|
||||
//if (fDebug)
|
||||
// printf("ProcessMessages(message %u msgsz, %zu bytes, complete:%s)\n",
|
||||
// LogPrintf("ProcessMessages(message %u msgsz, %zu bytes, complete:%s)\n",
|
||||
// msg.hdr.nMessageSize, msg.vRecv.size(),
|
||||
// msg.complete() ? "Y" : "N");
|
||||
|
||||
@ -4791,7 +4791,7 @@ bool ProcessMessages(CNode* pfrom)
|
||||
|
||||
// Scan for message start
|
||||
if (memcmp(msg.hdr.pchMessageStart, pchMessageStart, sizeof(pchMessageStart)) != 0) {
|
||||
printf("\n\nPROCESSMESSAGE: INVALID MESSAGESTART\n\n");
|
||||
LogPrintf("\n\nPROCESSMESSAGE: INVALID MESSAGESTART\n\n");
|
||||
fOk = false;
|
||||
break;
|
||||
}
|
||||
@ -4800,7 +4800,7 @@ bool ProcessMessages(CNode* pfrom)
|
||||
CMessageHeader& hdr = msg.hdr;
|
||||
if (!hdr.IsValid())
|
||||
{
|
||||
printf("\n\nPROCESSMESSAGE: ERRORS IN HEADER %s\n\n\n", hdr.GetCommand().c_str());
|
||||
LogPrintf("\n\nPROCESSMESSAGE: ERRORS IN HEADER %s\n\n\n", hdr.GetCommand().c_str());
|
||||
continue;
|
||||
}
|
||||
string strCommand = hdr.GetCommand();
|
||||
@ -4815,7 +4815,7 @@ bool ProcessMessages(CNode* pfrom)
|
||||
memcpy(&nChecksum, &hash, sizeof(nChecksum));
|
||||
if (nChecksum != hdr.nChecksum)
|
||||
{
|
||||
printf("ProcessMessages(%s, %u bytes) : CHECKSUM ERROR nChecksum=%08x hdr.nChecksum=%08x\n",
|
||||
LogPrintf("ProcessMessages(%s, %u bytes) : CHECKSUM ERROR nChecksum=%08x hdr.nChecksum=%08x\n",
|
||||
strCommand.c_str(), nMessageSize, nChecksum, hdr.nChecksum);
|
||||
continue;
|
||||
}
|
||||
@ -4835,12 +4835,12 @@ bool ProcessMessages(CNode* pfrom)
|
||||
if (strstr(e.what(), "end of data"))
|
||||
{
|
||||
// Allow exceptions from under-length message on vRecv
|
||||
printf("ProcessMessages(%s, %u bytes) : Exception '%s' caught, normally caused by a message being shorter than its stated length\n", strCommand.c_str(), nMessageSize, e.what());
|
||||
LogPrintf("ProcessMessages(%s, %u bytes) : Exception '%s' caught, normally caused by a message being shorter than its stated length\n", strCommand.c_str(), nMessageSize, e.what());
|
||||
}
|
||||
else if (strstr(e.what(), "size too large"))
|
||||
{
|
||||
// Allow exceptions from over-long size
|
||||
printf("ProcessMessages(%s, %u bytes) : Exception '%s' caught\n", strCommand.c_str(), nMessageSize, e.what());
|
||||
LogPrintf("ProcessMessages(%s, %u bytes) : Exception '%s' caught\n", strCommand.c_str(), nMessageSize, e.what());
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -4857,7 +4857,7 @@ bool ProcessMessages(CNode* pfrom)
|
||||
}
|
||||
|
||||
if (!fRet)
|
||||
printf("ProcessMessage(%s, %u bytes) FAILED\n", strCommand.c_str(), nMessageSize);
|
||||
LogPrintf("ProcessMessage(%s, %u bytes) FAILED\n", strCommand.c_str(), nMessageSize);
|
||||
|
||||
break;
|
||||
}
|
||||
@ -4896,7 +4896,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
|
||||
nAskedForBlocks++;
|
||||
pto->fAskedForBlocks = true;
|
||||
if (pto->PushGetBlocks(pindexBest, uint256(0)))
|
||||
printf("send initial getblocks peer=%d\n", pto->id);
|
||||
LogPrintf("send initial getblocks peer=%d\n", pto->id);
|
||||
}
|
||||
|
||||
// Resend wallet transactions that haven't gotten in a block yet
|
||||
@ -5027,7 +5027,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
|
||||
if (!AlreadyHave(inv))
|
||||
{
|
||||
if (fDebugNet)
|
||||
printf("sending getdata: %s peer=%d\n", inv.ToString().c_str(), pto->id);
|
||||
LogPrintf("sending getdata: %s peer=%d\n", inv.ToString().c_str(), pto->id);
|
||||
vGetData.push_back(inv);
|
||||
if (vGetData.size() >= 1000)
|
||||
{
|
||||
@ -5115,10 +5115,10 @@ public:
|
||||
|
||||
void print() const
|
||||
{
|
||||
printf("COrphan(hash=%s, dPriority=%.1f, dFeePerKb=%.1f)\n",
|
||||
LogPrintf("COrphan(hash=%s, dPriority=%.1f, dFeePerKb=%.1f)\n",
|
||||
ptx->GetHash().ToString().c_str(), dPriority, dFeePerKb);
|
||||
BOOST_FOREACH(uint256 hash, setDependsOn)
|
||||
printf(" setDependsOn %s\n", hash.ToString().c_str());
|
||||
LogPrintf(" setDependsOn %s\n", hash.ToString().c_str());
|
||||
}
|
||||
};
|
||||
|
||||
@ -5167,7 +5167,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
|
||||
txNew.vout.resize(1);
|
||||
txNew.vout[0].scriptPubKey = scriptPubKeyIn;
|
||||
|
||||
printf("%d\n", scriptPubKeyIn[0]);
|
||||
LogPrintf("%d\n", scriptPubKeyIn[0]);
|
||||
|
||||
|
||||
// start masternode payments
|
||||
@ -5205,7 +5205,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
|
||||
txNew.vout[payments-1].scriptPubKey.SetDestination(darkSendMasterNodes[winningNode].pubkey.GetID());
|
||||
txNew.vout[payments-1].nValue = 0;
|
||||
|
||||
printf("Masternode payment to %s\n", txNew.vout[payments-1].scriptPubKey.ToString().c_str());
|
||||
LogPrintf("Masternode payment to %s\n", txNew.vout[payments-1].scriptPubKey.ToString().c_str());
|
||||
}
|
||||
} else {
|
||||
CBlock blockLast;
|
||||
@ -5236,7 +5236,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
|
||||
txNew.vout[payments-1].scriptPubKey = mv1.GetPubKey();
|
||||
txNew.vout[payments-1].nValue = 0;
|
||||
|
||||
printf("Masternode payment to %s\n", txNew.vout[payments-1].scriptPubKey.ToString().c_str());
|
||||
LogPrintf("Masternode payment to %s\n", txNew.vout[payments-1].scriptPubKey.ToString().c_str());
|
||||
} else if (((pindexPrev->nHeight+1) - mv1.GetHeight()) < MASTERNODE_PAYMENTS_EXPIRATION) {
|
||||
pblock->vmn.push_back(mv1);
|
||||
}
|
||||
@ -5305,7 +5305,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
|
||||
// or other transactions in the memory pool.
|
||||
if (!mempool.mapTx.count(txin.prevout.hash))
|
||||
{
|
||||
printf("ERROR: mempool transaction missing input %s\n", txin.prevout.hash.ToString().c_str());
|
||||
LogPrintf("ERROR: mempool transaction missing input %s\n", txin.prevout.hash.ToString().c_str());
|
||||
if (!fTestNet && fDebug) assert("mempool transaction missing input" == 0);
|
||||
fMissingInputs = true;
|
||||
if (porphan)
|
||||
@ -5430,7 +5430,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
|
||||
|
||||
if (fPrintPriority)
|
||||
{
|
||||
printf("priority %.1f feeperkb %.1f txid %s\n",
|
||||
LogPrintf("priority %.1f feeperkb %.1f txid %s\n",
|
||||
dPriority, dFeePerKb, tx.GetHash().ToString().c_str());
|
||||
}
|
||||
|
||||
@ -5454,13 +5454,13 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
|
||||
|
||||
nLastBlockTx = nBlockTx;
|
||||
nLastBlockSize = nBlockSize;
|
||||
printf("CreateNewBlock(): total size %"PRI64u"\n", nBlockSize);
|
||||
LogPrintf("CreateNewBlock(): total size %"PRI64u"\n", nBlockSize);
|
||||
|
||||
int64 blockValue = GetBlockValue(pindexPrev->nBits, pindexPrev->nHeight, nFees);
|
||||
int64 blockValueFifth = blockValue/5;
|
||||
|
||||
for(int i = 1; i < payments; i++){
|
||||
printf("%d\n", i);
|
||||
LogPrintf("%d\n", i);
|
||||
pblock->vtx[0].vout[i].nValue = blockValueFifth;
|
||||
blockValue -= blockValueFifth;
|
||||
}
|
||||
@ -5575,10 +5575,10 @@ bool CheckWork(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey)
|
||||
return false;
|
||||
|
||||
//// debug print
|
||||
printf("DarkCoinMiner:\n");
|
||||
printf("proof-of-work found \n hash: %s \ntarget: %s\n", hash.GetHex().c_str(), hashTarget.GetHex().c_str());
|
||||
LogPrintf("DarkCoinMiner:\n");
|
||||
LogPrintf("proof-of-work found \n hash: %s \ntarget: %s\n", hash.GetHex().c_str(), hashTarget.GetHex().c_str());
|
||||
pblock->print();
|
||||
printf("generated %s\n", FormatMoney(pblock->vtx[0].vout[0].nValue).c_str());
|
||||
LogPrintf("generated %s\n", FormatMoney(pblock->vtx[0].vout[0].nValue).c_str());
|
||||
|
||||
// Found a solution
|
||||
{
|
||||
@ -5606,7 +5606,7 @@ bool CheckWork(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey)
|
||||
|
||||
void static DarkCoinMiner(CWallet *pwallet)
|
||||
{
|
||||
printf("DarkCoinMiner started\n");
|
||||
LogPrintf("DarkCoinMiner started\n");
|
||||
SetThreadPriority(THREAD_PRIORITY_LOWEST);
|
||||
RenameThread("darkcoin-miner");
|
||||
|
||||
@ -5630,7 +5630,7 @@ void static DarkCoinMiner(CWallet *pwallet)
|
||||
CBlock *pblock = &pblocktemplate->block;
|
||||
IncrementExtraNonce(pblock, pindexPrev, nExtraNonce);
|
||||
|
||||
printf("Running DarkCoinMiner with %"PRIszu" transactions in block (%u bytes)\n", pblock->vtx.size(),
|
||||
LogPrintf("Running DarkCoinMiner with %"PRIszu" transactions in block (%u bytes)\n", pblock->vtx.size(),
|
||||
::GetSerializeSize(*pblock, SER_NETWORK, PROTOCOL_VERSION));
|
||||
|
||||
//
|
||||
@ -5697,7 +5697,7 @@ void static DarkCoinMiner(CWallet *pwallet)
|
||||
if (GetTime() - nLogTime > 30 * 60)
|
||||
{
|
||||
nLogTime = GetTime();
|
||||
printf("hashmeter %6.0f khash/s\n", dHashesPerSec/1000.0);
|
||||
LogPrintf("hashmeter %6.0f khash/s\n", dHashesPerSec/1000.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -5727,7 +5727,7 @@ void static DarkCoinMiner(CWallet *pwallet)
|
||||
} }
|
||||
catch (boost::thread_interrupted)
|
||||
{
|
||||
printf("DarkCoinMiner terminated\n");
|
||||
LogPrintf("DarkCoinMiner terminated\n");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
@ -5844,7 +5844,7 @@ bool CDarkSendPool::SetCollateralAddress(std::string strAddress){
|
||||
CBitcoinAddress address;
|
||||
if (!address.SetString(strAddress))
|
||||
{
|
||||
printf("CDarkSendPool::SetCollateralAddress - Invalid DarkSend collateral address\n");
|
||||
LogPrintf("CDarkSendPool::SetCollateralAddress - Invalid DarkSend collateral address\n");
|
||||
return false;
|
||||
}
|
||||
collateralPubKey.SetDestination(address.Get());
|
||||
@ -5874,7 +5874,7 @@ bool CDarkSendPool::GetLastValidBlockHash(uint256& hash, int mod)
|
||||
|
||||
void CDarkSendPool::NewBlock()
|
||||
{
|
||||
if(fDebug) printf("CDarkSendPool::NewBlock \n");
|
||||
if(fDebug) LogPrintf("CDarkSendPool::NewBlock \n");
|
||||
|
||||
{
|
||||
LOCK2(cs_main, mempool.cs);
|
||||
@ -5905,11 +5905,11 @@ uint256 CMasterNode::CalculateScore(int mod)
|
||||
uint256 n3 = vin.prevout.hash > n2 ? (vin.prevout.hash - n2) : (n2 - vin.prevout.hash);
|
||||
|
||||
/*
|
||||
printf(" -- MasterNode CalculateScore() n1 = %s \n", n1.ToString().c_str());
|
||||
printf(" -- MasterNode CalculateScore() n11 = %u \n", n11);
|
||||
printf(" -- MasterNode CalculateScore() n2 = %s \n", n2.ToString().c_str());
|
||||
printf(" -- MasterNode CalculateScore() vin = %s \n", vin.prevout.hash.ToString().c_str());
|
||||
printf(" -- MasterNode CalculateScore() n3 = %s \n", n3.ToString().c_str());*/
|
||||
LogPrintf(" -- MasterNode CalculateScore() n1 = %s \n", n1.ToString().c_str());
|
||||
LogPrintf(" -- MasterNode CalculateScore() n11 = %u \n", n11);
|
||||
LogPrintf(" -- MasterNode CalculateScore() n2 = %s \n", n2.ToString().c_str());
|
||||
LogPrintf(" -- MasterNode CalculateScore() vin = %s \n", vin.prevout.hash.ToString().c_str());
|
||||
LogPrintf(" -- MasterNode CalculateScore() n3 = %s \n", n3.ToString().c_str());*/
|
||||
|
||||
return n3;
|
||||
}
|
||||
@ -5931,14 +5931,14 @@ int CDarkSendPool::GetCurrentMasterNode(int mod)
|
||||
unsigned int n2 = 0;
|
||||
memcpy(&n2, &n, sizeof(n2));
|
||||
|
||||
//printf("GetCurrentMasterNode: %d : %s : %u > %u\n", i, mn.addr.ToString().c_str(), n2, score);
|
||||
//LogPrintf("GetCurrentMasterNode: %d : %s : %u > %u\n", i, mn.addr.ToString().c_str(), n2, score);
|
||||
if(n2 > score){
|
||||
score = n2;
|
||||
winner = i;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
//printf("GetCurrentMasterNode: winner %d\n", winner);
|
||||
//LogPrintf("GetCurrentMasterNode: winner %d\n", winner);
|
||||
|
||||
return winner;
|
||||
}
|
||||
|
30
src/main.h
30
src/main.h
@ -340,7 +340,7 @@ public:
|
||||
|
||||
void print() const
|
||||
{
|
||||
printf("%s\n", ToString().c_str());
|
||||
LogPrintf("%s\n", ToString().c_str());
|
||||
}
|
||||
};
|
||||
|
||||
@ -418,7 +418,7 @@ public:
|
||||
|
||||
void print() const
|
||||
{
|
||||
printf("%s\n", ToString().c_str());
|
||||
LogPrintf("%s\n", ToString().c_str());
|
||||
}
|
||||
};
|
||||
|
||||
@ -489,7 +489,7 @@ public:
|
||||
|
||||
void print() const
|
||||
{
|
||||
printf("%s\n", ToString().c_str());
|
||||
LogPrintf("%s\n", ToString().c_str());
|
||||
}
|
||||
};
|
||||
|
||||
@ -695,7 +695,7 @@ void UpdateCoins(const CTransaction& tx, CValidationState &state, CCoinsViewCach
|
||||
|
||||
void print() const
|
||||
{
|
||||
printf("%s", ToString().c_str());
|
||||
LogPrintf("%s", ToString().c_str());
|
||||
}
|
||||
|
||||
|
||||
@ -1369,11 +1369,11 @@ public:
|
||||
(
|
||||
nVersion = this->nVersion;
|
||||
READWRITE(blockHeight);
|
||||
//printf("blockHeight %"PRI64d"\n", blockHeight);
|
||||
//LogPrintf("blockHeight %"PRI64d"\n", blockHeight);
|
||||
READWRITE(pubkey);
|
||||
//printf("pubkey %s\n", pubkey.ToString().c_str());
|
||||
//LogPrintf("pubkey %s\n", pubkey.ToString().c_str());
|
||||
READWRITE(votes);
|
||||
//printf("votes %d\n", votes);
|
||||
//LogPrintf("votes %d\n", votes);
|
||||
)
|
||||
|
||||
|
||||
@ -1608,7 +1608,7 @@ public:
|
||||
|
||||
void print() const
|
||||
{
|
||||
printf("CBlock(hash=%s, input=%s, PoW=%s, ver=%d, hashPrevBlock=%s, hashMerkleRoot=%s, nTime=%u, nBits=%08x, nNonce=%u, vtx=%"PRIszu")\n",
|
||||
LogPrintf("CBlock(hash=%s, input=%s, PoW=%s, ver=%d, hashPrevBlock=%s, hashMerkleRoot=%s, nTime=%u, nBits=%08x, nNonce=%u, vtx=%"PRIszu")\n",
|
||||
GetHash().ToString().c_str(),
|
||||
HexStr(BEGIN(nVersion),BEGIN(nVersion)+80,false).c_str(),
|
||||
GetPoWHash().ToString().c_str(),
|
||||
@ -1619,13 +1619,13 @@ public:
|
||||
vtx.size());
|
||||
for (unsigned int i = 0; i < vtx.size(); i++)
|
||||
{
|
||||
printf(" ");
|
||||
LogPrintf(" ");
|
||||
vtx[i].print();
|
||||
}
|
||||
printf(" vMerkleTree: ");
|
||||
LogPrintf(" vMerkleTree: ");
|
||||
for (unsigned int i = 0; i < vMerkleTree.size(); i++)
|
||||
printf("%s ", vMerkleTree[i].ToString().c_str());
|
||||
printf("\n");
|
||||
LogPrintf("%s ", vMerkleTree[i].ToString().c_str());
|
||||
LogPrintf("\n");
|
||||
}
|
||||
|
||||
|
||||
@ -1950,7 +1950,7 @@ public:
|
||||
|
||||
void print() const
|
||||
{
|
||||
printf("%s\n", ToString().c_str());
|
||||
LogPrintf("%s\n", ToString().c_str());
|
||||
}
|
||||
};
|
||||
|
||||
@ -2032,7 +2032,7 @@ public:
|
||||
|
||||
void print() const
|
||||
{
|
||||
printf("%s\n", ToString().c_str());
|
||||
LogPrintf("%s\n", ToString().c_str());
|
||||
}
|
||||
};
|
||||
|
||||
@ -2461,7 +2461,7 @@ public:
|
||||
|
||||
bool UpdatedWithin(int microSeconds)
|
||||
{
|
||||
//printf("UpdatedWithin %"PRI64u", %"PRI64u" -- %d \n", GetTimeMicros() , lastTimeSeen, (GetTimeMicros() - lastTimeSeen) < microSeconds);
|
||||
//LogPrintf("UpdatedWithin %"PRI64u", %"PRI64u" -- %d \n", GetTimeMicros() , lastTimeSeen, (GetTimeMicros() - lastTimeSeen) < microSeconds);
|
||||
|
||||
return (GetTimeMicros() - lastTimeSeen) < microSeconds;
|
||||
}
|
||||
|
92
src/net.cpp
92
src/net.cpp
@ -172,14 +172,14 @@ bool RecvLine(SOCKET hSocket, string& strLine)
|
||||
if (nBytes == 0)
|
||||
{
|
||||
// socket closed
|
||||
printf("socket closed\n");
|
||||
LogPrintf("socket closed\n");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// socket error
|
||||
int nErr = WSAGetLastError();
|
||||
printf("recv failed: %d\n", nErr);
|
||||
LogPrintf("recv failed: %d\n", nErr);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -225,7 +225,7 @@ bool AddLocal(const CService& addr, int nScore)
|
||||
if (IsLimited(addr))
|
||||
return false;
|
||||
|
||||
printf("AddLocal(%s,%i)\n", addr.ToString().c_str(), nScore);
|
||||
LogPrintf("AddLocal(%s,%i)\n", addr.ToString().c_str(), nScore);
|
||||
|
||||
{
|
||||
LOCK(cs_mapLocalHost);
|
||||
@ -333,7 +333,7 @@ bool GetMyExternalIP2(const CService& addrConnect, const char* pszGet, const cha
|
||||
while (strLine.size() > 0 && isspace(strLine[strLine.size()-1]))
|
||||
strLine.resize(strLine.size()-1);
|
||||
CService addr(strLine,0,true);
|
||||
printf("GetMyExternalIP() received [%s] %s\n", strLine.c_str(), addr.ToString().c_str());
|
||||
LogPrintf("GetMyExternalIP() received [%s] %s\n", strLine.c_str(), addr.ToString().c_str());
|
||||
if (!addr.IsValid() || !addr.IsRoutable())
|
||||
return false;
|
||||
ipRet.SetIP(addr);
|
||||
@ -411,7 +411,7 @@ void ThreadGetMyExternalIP(void* parg)
|
||||
CNetAddr addrLocalHost;
|
||||
if (GetMyExternalIP(addrLocalHost))
|
||||
{
|
||||
printf("GetMyExternalIP() returned %s\n", addrLocalHost.ToStringIP().c_str());
|
||||
LogPrintf("GetMyExternalIP() returned %s\n", addrLocalHost.ToStringIP().c_str());
|
||||
AddLocal(addrLocalHost, LOCAL_HTTP);
|
||||
}
|
||||
}
|
||||
@ -475,7 +475,7 @@ CNode* ConnectNode(CAddress addrConnect, const char *pszDest)
|
||||
|
||||
|
||||
/// debug print
|
||||
printf("trying connection %s lastseen=%.1fdays\n",
|
||||
LogPrintf("trying connection %s lastseen=%.1fdays\n",
|
||||
pszDest ? pszDest : addrConnect.ToString().c_str(),
|
||||
pszDest ? 0 : (double)(GetAdjustedTime() - addrConnect.nTime)/86400.0);
|
||||
|
||||
@ -486,16 +486,16 @@ CNode* ConnectNode(CAddress addrConnect, const char *pszDest)
|
||||
addrman.Attempt(addrConnect);
|
||||
|
||||
/// debug print
|
||||
printf("connected %s\n", pszDest ? pszDest : addrConnect.ToString().c_str());
|
||||
LogPrintf("connected %s\n", pszDest ? pszDest : addrConnect.ToString().c_str());
|
||||
|
||||
// Set to non-blocking
|
||||
#ifdef WIN32
|
||||
u_long nOne = 1;
|
||||
if (ioctlsocket(hSocket, FIONBIO, &nOne) == SOCKET_ERROR)
|
||||
printf("ConnectSocket() : ioctlsocket non-blocking setting failed, error %d\n", WSAGetLastError());
|
||||
LogPrintf("ConnectSocket() : ioctlsocket non-blocking setting failed, error %d\n", WSAGetLastError());
|
||||
#else
|
||||
if (fcntl(hSocket, F_SETFL, O_NONBLOCK) == SOCKET_ERROR)
|
||||
printf("ConnectSocket() : fcntl non-blocking setting failed, error %d\n", errno);
|
||||
LogPrintf("ConnectSocket() : fcntl non-blocking setting failed, error %d\n", errno);
|
||||
#endif
|
||||
|
||||
// Add node
|
||||
@ -521,7 +521,7 @@ void CNode::CloseSocketDisconnect()
|
||||
fDisconnect = true;
|
||||
if (hSocket != INVALID_SOCKET)
|
||||
{
|
||||
printf("disconnecting node %s\n", addrName.c_str());
|
||||
LogPrintf("disconnecting node %s\n", addrName.c_str());
|
||||
closesocket(hSocket);
|
||||
hSocket = INVALID_SOCKET;
|
||||
}
|
||||
@ -548,7 +548,7 @@ void CNode::PushVersion()
|
||||
CAddress addrYou = (addr.IsRoutable() && !IsProxy(addr) ? addr : CAddress(CService("0.0.0.0",0)));
|
||||
CAddress addrMe = GetLocalAddress(&addr);
|
||||
RAND_bytes((unsigned char*)&nLocalHostNonce, sizeof(nLocalHostNonce));
|
||||
printf("send version message: version %d, blocks=%d, us=%s, them=%s, peer=%d\n", PROTOCOL_VERSION, nBestHeight, addrMe.ToString().c_str(), addrYou.ToString().c_str(), id);
|
||||
LogPrintf("send version message: version %d, blocks=%d, us=%s, them=%s, peer=%d\n", PROTOCOL_VERSION, nBestHeight, addrMe.ToString().c_str(), addrYou.ToString().c_str(), id);
|
||||
PushMessage("version", PROTOCOL_VERSION, nLocalServices, nTime, addrYou, addrMe,
|
||||
nLocalHostNonce, FormatSubVersion(CLIENT_NAME, CLIENT_VERSION, std::vector<string>()), nBestHeight);
|
||||
}
|
||||
@ -585,7 +585,7 @@ bool CNode::Misbehaving(int howmuch)
|
||||
{
|
||||
if (addr.IsLocal())
|
||||
{
|
||||
printf("Warning: Local node %s misbehaving (delta: %d)!\n", addrName.c_str(), howmuch);
|
||||
LogPrintf("Warning: Local node %s misbehaving (delta: %d)!\n", addrName.c_str(), howmuch);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -594,7 +594,7 @@ bool CNode::Misbehaving(int howmuch)
|
||||
if (nMisbehavior >= GetArg("-banscore", 100))
|
||||
{
|
||||
int64 banTime = GetTime()+GetArg("-bantime", 60*60*24); // Default 24-hour ban
|
||||
printf("Misbehaving: %s (%d -> %d) DISCONNECTING\n", addr.ToString().c_str(), nMisbehavior-howmuch, nMisbehavior);
|
||||
LogPrintf("Misbehaving: %s (%d -> %d) DISCONNECTING\n", addr.ToString().c_str(), nMisbehavior-howmuch, nMisbehavior);
|
||||
{
|
||||
LOCK(cs_setBanned);
|
||||
if (setBanned[addr] < banTime)
|
||||
@ -603,7 +603,7 @@ bool CNode::Misbehaving(int howmuch)
|
||||
CloseSocketDisconnect();
|
||||
return true;
|
||||
} else
|
||||
printf("Misbehaving: %s (%d -> %d)\n", addr.ToString().c_str(), nMisbehavior-howmuch, nMisbehavior);
|
||||
LogPrintf("Misbehaving: %s (%d -> %d)\n", addr.ToString().c_str(), nMisbehavior-howmuch, nMisbehavior);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -735,7 +735,7 @@ void SocketSendData(CNode *pnode)
|
||||
int nErr = WSAGetLastError();
|
||||
if (nErr != WSAEWOULDBLOCK && nErr != WSAEMSGSIZE && nErr != WSAEINTR && nErr != WSAEINPROGRESS)
|
||||
{
|
||||
printf("socket send error %d\n", nErr);
|
||||
LogPrintf("socket send error %d\n", nErr);
|
||||
pnode->CloseSocketDisconnect();
|
||||
}
|
||||
}
|
||||
@ -895,7 +895,7 @@ void ThreadSocketHandler()
|
||||
if (have_fds)
|
||||
{
|
||||
int nErr = WSAGetLastError();
|
||||
printf("socket select error %d\n", nErr);
|
||||
LogPrintf("socket select error %d\n", nErr);
|
||||
for (unsigned int i = 0; i <= hSocketMax; i++)
|
||||
FD_SET(i, &fdsetRecv);
|
||||
}
|
||||
@ -923,7 +923,7 @@ void ThreadSocketHandler()
|
||||
|
||||
if (hSocket != INVALID_SOCKET)
|
||||
if (!addr.SetSockAddr((const struct sockaddr*)&sockaddr))
|
||||
printf("Warning: Unknown socket family\n");
|
||||
LogPrintf("Warning: Unknown socket family\n");
|
||||
|
||||
{
|
||||
LOCK(cs_vNodes);
|
||||
@ -936,7 +936,7 @@ void ThreadSocketHandler()
|
||||
{
|
||||
int nErr = WSAGetLastError();
|
||||
if (nErr != WSAEWOULDBLOCK)
|
||||
printf("socket error accept failed: %d\n", nErr);
|
||||
LogPrintf("socket error accept failed: %d\n", nErr);
|
||||
}
|
||||
else if (nInbound >= nMaxConnections - MAX_OUTBOUND_CONNECTIONS)
|
||||
{
|
||||
@ -948,12 +948,12 @@ void ThreadSocketHandler()
|
||||
}
|
||||
else if (CNode::IsBanned(addr))
|
||||
{
|
||||
printf("connection from %s dropped (banned)\n", addr.ToString().c_str());
|
||||
LogPrintf("connection from %s dropped (banned)\n", addr.ToString().c_str());
|
||||
closesocket(hSocket);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("accepted connection %s\n", addr.ToString().c_str());
|
||||
LogPrintf("accepted connection %s\n", addr.ToString().c_str());
|
||||
CNode* pnode = new CNode(hSocket, addr, "", true);
|
||||
pnode->AddRef();
|
||||
{
|
||||
@ -1003,7 +1003,7 @@ void ThreadSocketHandler()
|
||||
{
|
||||
// socket closed gracefully
|
||||
if (!pnode->fDisconnect)
|
||||
printf("socket closed\n");
|
||||
LogPrintf("socket closed\n");
|
||||
pnode->CloseSocketDisconnect();
|
||||
}
|
||||
else if (nBytes < 0)
|
||||
@ -1013,7 +1013,7 @@ void ThreadSocketHandler()
|
||||
if (nErr != WSAEWOULDBLOCK && nErr != WSAEMSGSIZE && nErr != WSAEINTR && nErr != WSAEINPROGRESS)
|
||||
{
|
||||
if (!pnode->fDisconnect)
|
||||
printf("socket recv error %d\n", nErr);
|
||||
LogPrintf("socket recv error %d\n", nErr);
|
||||
pnode->CloseSocketDisconnect();
|
||||
}
|
||||
}
|
||||
@ -1042,17 +1042,17 @@ void ThreadSocketHandler()
|
||||
{
|
||||
if (pnode->nLastRecv == 0 || pnode->nLastSend == 0)
|
||||
{
|
||||
printf("socket no message in first 60 seconds, %d %d\n", pnode->nLastRecv != 0, pnode->nLastSend != 0);
|
||||
LogPrintf("socket no message in first 60 seconds, %d %d\n", pnode->nLastRecv != 0, pnode->nLastSend != 0);
|
||||
pnode->fDisconnect = true;
|
||||
}
|
||||
else if (GetTime() - pnode->nLastSend > 90*60 && GetTime() - pnode->nLastSendEmpty > 90*60)
|
||||
{
|
||||
printf("socket not sending\n");
|
||||
LogPrintf("socket not sending\n");
|
||||
pnode->fDisconnect = true;
|
||||
}
|
||||
else if (GetTime() - pnode->nLastRecv > 90*60)
|
||||
{
|
||||
printf("socket inactivity timeout\n");
|
||||
LogPrintf("socket inactivity timeout\n");
|
||||
pnode->fDisconnect = true;
|
||||
}
|
||||
}
|
||||
@ -1104,16 +1104,16 @@ void ThreadMapPort()
|
||||
char externalIPAddress[40];
|
||||
r = UPNP_GetExternalIPAddress(urls.controlURL, data.first.servicetype, externalIPAddress);
|
||||
if(r != UPNPCOMMAND_SUCCESS)
|
||||
printf("UPnP: GetExternalIPAddress() returned %d\n", r);
|
||||
LogPrintf("UPnP: GetExternalIPAddress() returned %d\n", r);
|
||||
else
|
||||
{
|
||||
if(externalIPAddress[0])
|
||||
{
|
||||
printf("UPnP: ExternalIPAddress = %s\n", externalIPAddress);
|
||||
LogPrintf("UPnP: ExternalIPAddress = %s\n", externalIPAddress);
|
||||
AddLocal(CNetAddr(externalIPAddress), LOCAL_UPNP);
|
||||
}
|
||||
else
|
||||
printf("UPnP: GetExternalIPAddress failed.\n");
|
||||
LogPrintf("UPnP: GetExternalIPAddress failed.\n");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1132,10 +1132,10 @@ void ThreadMapPort()
|
||||
#endif
|
||||
|
||||
if(r!=UPNPCOMMAND_SUCCESS)
|
||||
printf("AddPortMapping(%s, %s, %s) failed with code %d (%s)\n",
|
||||
LogPrintf("AddPortMapping(%s, %s, %s) failed with code %d (%s)\n",
|
||||
port.c_str(), port.c_str(), lanaddr, r, strupnperror(r));
|
||||
else
|
||||
printf("UPnP Port Mapping successful.\n");;
|
||||
LogPrintf("UPnP Port Mapping successful.\n");;
|
||||
|
||||
MilliSleep(20*60*1000); // Refresh every 20 minutes
|
||||
}
|
||||
@ -1143,13 +1143,13 @@ void ThreadMapPort()
|
||||
catch (boost::thread_interrupted)
|
||||
{
|
||||
r = UPNP_DeletePortMapping(urls.controlURL, data.first.servicetype, port.c_str(), "TCP", 0);
|
||||
printf("UPNP_DeletePortMapping() returned : %d\n", r);
|
||||
LogPrintf("UPNP_DeletePortMapping() returned : %d\n", r);
|
||||
freeUPNPDevlist(devlist); devlist = 0;
|
||||
FreeUPNPUrls(&urls);
|
||||
throw;
|
||||
}
|
||||
} else {
|
||||
printf("No valid UPnP IGDs found\n");
|
||||
LogPrintf("No valid UPnP IGDs found\n");
|
||||
freeUPNPDevlist(devlist); devlist = 0;
|
||||
if (r != 0)
|
||||
FreeUPNPUrls(&urls);
|
||||
@ -1214,7 +1214,7 @@ void ThreadDNSAddressSeed()
|
||||
|
||||
int found = 0;
|
||||
|
||||
printf("Loading addresses from DNS seeds (could take a while)\n");
|
||||
LogPrintf("Loading addresses from DNS seeds (could take a while)\n");
|
||||
|
||||
for (unsigned int seed_idx = 0; strDNSSeed[seed_idx][0] != NULL; seed_idx++) {
|
||||
if (HaveNameProxy()) {
|
||||
@ -1239,7 +1239,7 @@ void ThreadDNSAddressSeed()
|
||||
}
|
||||
}
|
||||
|
||||
printf("%d addresses found from DNS seeds\n", found);
|
||||
LogPrintf("%d addresses found from DNS seeds\n", found);
|
||||
}
|
||||
|
||||
|
||||
@ -1266,7 +1266,7 @@ void DumpAddresses()
|
||||
CAddrDB adb;
|
||||
adb.Write(addrman);
|
||||
|
||||
printf("Flushed %d addresses to peers.dat %"PRI64d"ms\n",
|
||||
LogPrintf("Flushed %d addresses to peers.dat %"PRI64d"ms\n",
|
||||
addrman.size(), GetTimeMillis() - nStart);
|
||||
}
|
||||
|
||||
@ -1629,7 +1629,7 @@ bool BindListenPort(const CService &addrBind, string& strError)
|
||||
if (!addrBind.GetSockAddr((struct sockaddr*)&sockaddr, &len))
|
||||
{
|
||||
strError = strprintf("Error: bind address family for %s not supported", addrBind.ToString().c_str());
|
||||
printf("%s\n", strError.c_str());
|
||||
LogPrintf("%s\n", strError.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1637,7 +1637,7 @@ bool BindListenPort(const CService &addrBind, string& strError)
|
||||
if (hListenSocket == INVALID_SOCKET)
|
||||
{
|
||||
strError = strprintf("Error: Couldn't open socket for incoming connections (socket returned error %d)", WSAGetLastError());
|
||||
printf("%s\n", strError.c_str());
|
||||
LogPrintf("%s\n", strError.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1661,7 +1661,7 @@ bool BindListenPort(const CService &addrBind, string& strError)
|
||||
#endif
|
||||
{
|
||||
strError = strprintf("Error: Couldn't set properties on socket for incoming connections (error %d)", WSAGetLastError());
|
||||
printf("%s\n", strError.c_str());
|
||||
LogPrintf("%s\n", strError.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1692,16 +1692,16 @@ bool BindListenPort(const CService &addrBind, string& strError)
|
||||
strError = strprintf(_("Unable to bind to %s on this computer. DarkCoin is probably already running."), addrBind.ToString().c_str());
|
||||
else
|
||||
strError = strprintf(_("Unable to bind to %s on this computer (bind returned error %d, %s)"), addrBind.ToString().c_str(), nErr, strerror(nErr));
|
||||
printf("%s\n", strError.c_str());
|
||||
LogPrintf("%s\n", strError.c_str());
|
||||
return false;
|
||||
}
|
||||
printf("Bound to %s\n", addrBind.ToString().c_str());
|
||||
LogPrintf("Bound to %s\n", addrBind.ToString().c_str());
|
||||
|
||||
// Listen for incoming connections
|
||||
if (listen(hListenSocket, SOMAXCONN) == SOCKET_ERROR)
|
||||
{
|
||||
strError = strprintf("Error: Listening for incoming connections failed (listen returned error %d)", WSAGetLastError());
|
||||
printf("%s\n", strError.c_str());
|
||||
LogPrintf("%s\n", strError.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1748,7 +1748,7 @@ void static Discover()
|
||||
struct sockaddr_in* s4 = (struct sockaddr_in*)(ifa->ifa_addr);
|
||||
CNetAddr addr(s4->sin_addr);
|
||||
if (AddLocal(addr, LOCAL_IF))
|
||||
printf("IPv4 %s: %s\n", ifa->ifa_name, addr.ToString().c_str());
|
||||
LogPrintf("IPv4 %s: %s\n", ifa->ifa_name, addr.ToString().c_str());
|
||||
}
|
||||
#ifdef USE_IPV6
|
||||
else if (ifa->ifa_addr->sa_family == AF_INET6)
|
||||
@ -1756,7 +1756,7 @@ void static Discover()
|
||||
struct sockaddr_in6* s6 = (struct sockaddr_in6*)(ifa->ifa_addr);
|
||||
CNetAddr addr(s6->sin6_addr);
|
||||
if (AddLocal(addr, LOCAL_IF))
|
||||
printf("IPv6 %s: %s\n", ifa->ifa_name, addr.ToString().c_str());
|
||||
LogPrintf("IPv6 %s: %s\n", ifa->ifa_name, addr.ToString().c_str());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -1787,7 +1787,7 @@ void StartNode(boost::thread_group& threadGroup)
|
||||
//
|
||||
|
||||
if (!GetBoolArg("-dnsseed", true))
|
||||
printf("DNS seeding disabled\n");
|
||||
LogPrintf("DNS seeding disabled\n");
|
||||
else
|
||||
threadGroup.create_thread(boost::bind(&TraceThread<boost::function<void()> >, "dnsseed", &ThreadDNSAddressSeed));
|
||||
|
||||
@ -1814,7 +1814,7 @@ void StartNode(boost::thread_group& threadGroup)
|
||||
|
||||
bool StopNode()
|
||||
{
|
||||
printf("StopNode()\n");
|
||||
LogPrintf("StopNode()\n");
|
||||
GenerateBitcoins(false, NULL);
|
||||
MapPort(false);
|
||||
nTransactionsUpdated++;
|
||||
@ -1842,7 +1842,7 @@ public:
|
||||
BOOST_FOREACH(SOCKET hListenSocket, vhListenSocket)
|
||||
if (hListenSocket != INVALID_SOCKET)
|
||||
if (closesocket(hListenSocket) == SOCKET_ERROR)
|
||||
printf("closesocket(hListenSocket) failed with error %d\n", WSAGetLastError());
|
||||
LogPrintf("closesocket(hListenSocket) failed with error %d\n", WSAGetLastError());
|
||||
|
||||
// clean up some globals (to help leak detection)
|
||||
BOOST_FOREACH(CNode *pnode, vNodes)
|
||||
|
10
src/net.h
10
src/net.h
@ -380,7 +380,7 @@ public:
|
||||
else
|
||||
nRequestTime = 0;
|
||||
if (fDebugNet)
|
||||
printf("askfor %s %"PRI64d" (%s)\n", inv.ToString().c_str(), nRequestTime, DateTimeStrFormat("%H:%M:%S", nRequestTime/1000000).c_str());
|
||||
LogPrintf("askfor %s %"PRI64d" (%s)\n", inv.ToString().c_str(), nRequestTime, DateTimeStrFormat("%H:%M:%S", nRequestTime/1000000).c_str());
|
||||
|
||||
// Make sure not to reuse time indexes to keep things in the same order
|
||||
int64 nNow = (GetTime() - 1) * 1000000;
|
||||
@ -407,7 +407,7 @@ public:
|
||||
assert(ssSend.size() == 0);
|
||||
ssSend << CMessageHeader(pszCommand, 0);
|
||||
if (fDebug)
|
||||
printf("sending: %s ", pszCommand);
|
||||
LogPrintf("sending: %s ", pszCommand);
|
||||
}
|
||||
|
||||
// TODO: Document the precondition of this function. Is cs_vSend locked?
|
||||
@ -418,7 +418,7 @@ public:
|
||||
LEAVE_CRITICAL_SECTION(cs_vSend);
|
||||
|
||||
if (fDebug)
|
||||
printf("(aborted)\n");
|
||||
LogPrintf("(aborted)\n");
|
||||
}
|
||||
|
||||
// TODO: Document the precondition of this function. Is cs_vSend locked?
|
||||
@ -426,7 +426,7 @@ public:
|
||||
{
|
||||
if (mapArgs.count("-dropmessagestest") && GetRand(atoi(mapArgs["-dropmessagestest"])) == 0)
|
||||
{
|
||||
printf("dropmessages DROPPING SEND MESSAGE\n");
|
||||
LogPrintf("dropmessages DROPPING SEND MESSAGE\n");
|
||||
AbortMessage();
|
||||
return;
|
||||
}
|
||||
@ -446,7 +446,7 @@ public:
|
||||
memcpy((char*)&ssSend[CMessageHeader::CHECKSUM_OFFSET], &nChecksum, sizeof(nChecksum));
|
||||
|
||||
if (fDebug) {
|
||||
printf("(%d bytes)\n", nSize);
|
||||
LogPrintf("(%d bytes)\n", nSize);
|
||||
}
|
||||
|
||||
std::deque<CSerializeData>::iterator it = vSendMsg.insert(vSendMsg.end(), CSerializeData());
|
||||
|
@ -166,7 +166,7 @@ bool LookupNumeric(const char *pszName, CService& addr, int portDefault)
|
||||
|
||||
bool static Socks4(const CService &addrDest, SOCKET& hSocket)
|
||||
{
|
||||
printf("SOCKS4 connecting %s\n", addrDest.ToString().c_str());
|
||||
LogPrintf("SOCKS4 connecting %s\n", addrDest.ToString().c_str());
|
||||
if (!addrDest.IsIPv4())
|
||||
{
|
||||
closesocket(hSocket);
|
||||
@ -201,16 +201,16 @@ bool static Socks4(const CService &addrDest, SOCKET& hSocket)
|
||||
{
|
||||
closesocket(hSocket);
|
||||
if (pchRet[1] != 0x5b)
|
||||
printf("ERROR: Proxy returned error %d\n", pchRet[1]);
|
||||
LogPrintf("ERROR: Proxy returned error %d\n", pchRet[1]);
|
||||
return false;
|
||||
}
|
||||
printf("SOCKS4 connected %s\n", addrDest.ToString().c_str());
|
||||
LogPrintf("SOCKS4 connected %s\n", addrDest.ToString().c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool static Socks5(string strDest, int port, SOCKET& hSocket)
|
||||
{
|
||||
printf("SOCKS5 connecting %s\n", strDest.c_str());
|
||||
LogPrintf("SOCKS5 connecting %s\n", strDest.c_str());
|
||||
if (strDest.size() > 255)
|
||||
{
|
||||
closesocket(hSocket);
|
||||
@ -306,7 +306,7 @@ bool static Socks5(string strDest, int port, SOCKET& hSocket)
|
||||
closesocket(hSocket);
|
||||
return error("Error reading from proxy");
|
||||
}
|
||||
printf("SOCKS5 connected %s\n", strDest.c_str());
|
||||
LogPrintf("SOCKS5 connected %s\n", strDest.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -321,7 +321,7 @@ bool static ConnectSocketDirectly(const CService &addrConnect, SOCKET& hSocketRe
|
||||
#endif
|
||||
socklen_t len = sizeof(sockaddr);
|
||||
if (!addrConnect.GetSockAddr((struct sockaddr*)&sockaddr, &len)) {
|
||||
printf("Cannot connect to %s: unsupported network\n", addrConnect.ToString().c_str());
|
||||
LogPrintf("Cannot connect to %s: unsupported network\n", addrConnect.ToString().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -360,13 +360,13 @@ bool static ConnectSocketDirectly(const CService &addrConnect, SOCKET& hSocketRe
|
||||
int nRet = select(hSocket + 1, NULL, &fdset, NULL, &timeout);
|
||||
if (nRet == 0)
|
||||
{
|
||||
printf("connection timeout\n");
|
||||
LogPrintf("connection timeout\n");
|
||||
closesocket(hSocket);
|
||||
return false;
|
||||
}
|
||||
if (nRet == SOCKET_ERROR)
|
||||
{
|
||||
printf("select() for connection failed: %i\n",WSAGetLastError());
|
||||
LogPrintf("select() for connection failed: %i\n",WSAGetLastError());
|
||||
closesocket(hSocket);
|
||||
return false;
|
||||
}
|
||||
@ -377,13 +377,13 @@ bool static ConnectSocketDirectly(const CService &addrConnect, SOCKET& hSocketRe
|
||||
if (getsockopt(hSocket, SOL_SOCKET, SO_ERROR, &nRet, &nRetSize) == SOCKET_ERROR)
|
||||
#endif
|
||||
{
|
||||
printf("getsockopt() for connection failed: %i\n",WSAGetLastError());
|
||||
LogPrintf("getsockopt() for connection failed: %i\n",WSAGetLastError());
|
||||
closesocket(hSocket);
|
||||
return false;
|
||||
}
|
||||
if (nRet != 0)
|
||||
{
|
||||
printf("connect() failed after select(): %s\n",strerror(nRet));
|
||||
LogPrintf("connect() failed after select(): %s\n",strerror(nRet));
|
||||
closesocket(hSocket);
|
||||
return false;
|
||||
}
|
||||
@ -394,7 +394,7 @@ bool static ConnectSocketDirectly(const CService &addrConnect, SOCKET& hSocketRe
|
||||
else
|
||||
#endif
|
||||
{
|
||||
printf("connect() failed: %i\n",WSAGetLastError());
|
||||
LogPrintf("connect() failed: %i\n",WSAGetLastError());
|
||||
closesocket(hSocket);
|
||||
return false;
|
||||
}
|
||||
@ -890,7 +890,7 @@ uint64 CNetAddr::GetHash() const
|
||||
|
||||
void CNetAddr::print() const
|
||||
{
|
||||
printf("CNetAddr(%s)\n", ToString().c_str());
|
||||
LogPrintf("CNetAddr(%s)\n", ToString().c_str());
|
||||
}
|
||||
|
||||
// private extensions to enum Network, only returned by GetExtNetwork,
|
||||
@ -1131,7 +1131,7 @@ std::string CService::ToString() const
|
||||
|
||||
void CService::print() const
|
||||
{
|
||||
printf("CService(%s)\n", ToString().c_str());
|
||||
LogPrintf("CService(%s)\n", ToString().c_str());
|
||||
}
|
||||
|
||||
void CService::SetPort(unsigned short portIn)
|
||||
|
@ -27,7 +27,7 @@ static bool noui_ThreadSafeMessageBox(const std::string& message, const std::str
|
||||
strCaption += caption; // Use supplied caption (can be empty)
|
||||
}
|
||||
|
||||
printf("%s: %s\n", strCaption.c_str(), message.c_str());
|
||||
LogPrintf("%s: %s\n", strCaption.c_str(), message.c_str());
|
||||
fprintf(stderr, "%s: %s\n", strCaption.c_str(), message.c_str());
|
||||
return false;
|
||||
}
|
||||
@ -39,7 +39,7 @@ static bool noui_ThreadSafeAskFee(int64 /*nFeeRequired*/)
|
||||
|
||||
static void noui_InitMessage(const std::string &message)
|
||||
{
|
||||
printf("init message: %s\n", message.c_str());
|
||||
LogPrintf("init message: %s\n", message.c_str());
|
||||
}
|
||||
|
||||
void noui_connect()
|
||||
|
@ -93,7 +93,7 @@ bool CMessageHeader::IsValid() const
|
||||
// Message size
|
||||
if (nMessageSize > MAX_SIZE)
|
||||
{
|
||||
printf("CMessageHeader::IsValid() : (%s, %u bytes) nMessageSize > MAX_SIZE\n", GetCommand().c_str(), nMessageSize);
|
||||
LogPrintf("CMessageHeader::IsValid() : (%s, %u bytes) nMessageSize > MAX_SIZE\n", GetCommand().c_str(), nMessageSize);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -172,6 +172,6 @@ std::string CInv::ToString() const
|
||||
|
||||
void CInv::print() const
|
||||
{
|
||||
printf("CInv(%s)\n", ToString().c_str());
|
||||
LogPrintf("CInv(%s)\n", ToString().c_str());
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,7 @@ public:
|
||||
case CT_NEW:
|
||||
if(inModel)
|
||||
{
|
||||
OutputDebugStringF("Warning: AddressTablePriv::updateEntry: Got CT_NOW, but entry is already in model\n");
|
||||
LogPrintf("Warning: AddressTablePriv::updateEntry: Got CT_NOW, but entry is already in model\n");
|
||||
break;
|
||||
}
|
||||
parent->beginInsertRows(QModelIndex(), lowerIndex, lowerIndex);
|
||||
@ -100,7 +100,7 @@ public:
|
||||
case CT_UPDATED:
|
||||
if(!inModel)
|
||||
{
|
||||
OutputDebugStringF("Warning: AddressTablePriv::updateEntry: Got CT_UPDATED, but entry is not in model\n");
|
||||
LogPrintf("Warning: AddressTablePriv::updateEntry: Got CT_UPDATED, but entry is not in model\n");
|
||||
break;
|
||||
}
|
||||
lower->type = newEntryType;
|
||||
@ -110,7 +110,7 @@ public:
|
||||
case CT_DELETED:
|
||||
if(!inModel)
|
||||
{
|
||||
OutputDebugStringF("Warning: AddressTablePriv::updateEntry: Got CT_DELETED, but entry is not in model\n");
|
||||
LogPrintf("Warning: AddressTablePriv::updateEntry: Got CT_DELETED, but entry is not in model\n");
|
||||
break;
|
||||
}
|
||||
parent->beginRemoveRows(QModelIndex(), lowerIndex, upperIndex-1);
|
||||
|
@ -179,14 +179,14 @@ static void NotifyBlocksChanged(ClientModel *clientmodel)
|
||||
|
||||
static void NotifyNumConnectionsChanged(ClientModel *clientmodel, int newNumConnections)
|
||||
{
|
||||
// Too noisy: OutputDebugStringF("NotifyNumConnectionsChanged %i\n", newNumConnections);
|
||||
// Too noisy: LogPrintf("NotifyNumConnectionsChanged %i\n", newNumConnections);
|
||||
QMetaObject::invokeMethod(clientmodel, "updateNumConnections", Qt::QueuedConnection,
|
||||
Q_ARG(int, newNumConnections));
|
||||
}
|
||||
|
||||
static void NotifyAlertChanged(ClientModel *clientmodel, const uint256 &hash, ChangeType status)
|
||||
{
|
||||
OutputDebugStringF("NotifyAlertChanged %s status=%i\n", hash.GetHex().c_str(), status);
|
||||
LogPrintf("NotifyAlertChanged %s status=%i\n", hash.GetHex().c_str(), status);
|
||||
QMetaObject::invokeMethod(clientmodel, "updateAlert", Qt::QueuedConnection,
|
||||
Q_ARG(QString, QString::fromStdString(hash.GetHex())),
|
||||
Q_ARG(int, status));
|
||||
|
@ -66,7 +66,7 @@ public:
|
||||
*/
|
||||
void refreshWallet()
|
||||
{
|
||||
OutputDebugStringF("refreshWallet\n");
|
||||
LogPrintf("refreshWallet\n");
|
||||
cachedWallet.clear();
|
||||
{
|
||||
LOCK(wallet->cs_wallet);
|
||||
@ -85,7 +85,7 @@ public:
|
||||
*/
|
||||
void updateWallet(const uint256 &hash, int status)
|
||||
{
|
||||
OutputDebugStringF("updateWallet %s %i\n", hash.ToString().c_str(), status);
|
||||
LogPrintf("updateWallet %s %i\n", hash.ToString().c_str(), status);
|
||||
{
|
||||
LOCK(wallet->cs_wallet);
|
||||
|
||||
@ -113,7 +113,7 @@ public:
|
||||
status = CT_DELETED; /* In model, but want to hide, treat as deleted */
|
||||
}
|
||||
|
||||
OutputDebugStringF(" inWallet=%i inModel=%i Index=%i-%i showTransaction=%i derivedStatus=%i\n",
|
||||
LogPrintf(" inWallet=%i inModel=%i Index=%i-%i showTransaction=%i derivedStatus=%i\n",
|
||||
inWallet, inModel, lowerIndex, upperIndex, showTransaction, status);
|
||||
|
||||
switch(status)
|
||||
@ -121,12 +121,12 @@ public:
|
||||
case CT_NEW:
|
||||
if(inModel)
|
||||
{
|
||||
OutputDebugStringF("Warning: updateWallet: Got CT_NEW, but transaction is already in model\n");
|
||||
LogPrintf("Warning: updateWallet: Got CT_NEW, but transaction is already in model\n");
|
||||
break;
|
||||
}
|
||||
if(!inWallet)
|
||||
{
|
||||
OutputDebugStringF("Warning: updateWallet: Got CT_NEW, but transaction is not in wallet\n");
|
||||
LogPrintf("Warning: updateWallet: Got CT_NEW, but transaction is not in wallet\n");
|
||||
break;
|
||||
}
|
||||
if(showTransaction)
|
||||
@ -150,7 +150,7 @@ public:
|
||||
case CT_DELETED:
|
||||
if(!inModel)
|
||||
{
|
||||
OutputDebugStringF("Warning: updateWallet: Got CT_DELETED, but transaction is not in model\n");
|
||||
LogPrintf("Warning: updateWallet: Got CT_DELETED, but transaction is not in model\n");
|
||||
break;
|
||||
}
|
||||
// Removed -- remove entire transaction from table
|
||||
|
@ -318,13 +318,13 @@ bool WalletModel::backupWallet(const QString &filename)
|
||||
// Handlers for core signals
|
||||
static void NotifyKeyStoreStatusChanged(WalletModel *walletmodel, CCryptoKeyStore *wallet)
|
||||
{
|
||||
OutputDebugStringF("NotifyKeyStoreStatusChanged\n");
|
||||
LogPrintf("NotifyKeyStoreStatusChanged\n");
|
||||
QMetaObject::invokeMethod(walletmodel, "updateStatus", Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
static void NotifyAddressBookChanged(WalletModel *walletmodel, CWallet *wallet, const CTxDestination &address, const std::string &label, bool isMine, ChangeType status)
|
||||
{
|
||||
OutputDebugStringF("NotifyAddressBookChanged %s %s isMine=%i status=%i\n", CBitcoinAddress(address).ToString().c_str(), label.c_str(), isMine, status);
|
||||
LogPrintf("NotifyAddressBookChanged %s %s isMine=%i status=%i\n", CBitcoinAddress(address).ToString().c_str(), label.c_str(), isMine, status);
|
||||
QMetaObject::invokeMethod(walletmodel, "updateAddressBook", Qt::QueuedConnection,
|
||||
Q_ARG(QString, QString::fromStdString(CBitcoinAddress(address).ToString())),
|
||||
Q_ARG(QString, QString::fromStdString(label)),
|
||||
@ -334,7 +334,7 @@ static void NotifyAddressBookChanged(WalletModel *walletmodel, CWallet *wallet,
|
||||
|
||||
static void NotifyTransactionChanged(WalletModel *walletmodel, CWallet *wallet, const uint256 &hash, ChangeType status)
|
||||
{
|
||||
OutputDebugStringF("NotifyTransactionChanged %s status=%i\n", hash.GetHex().c_str(), status);
|
||||
LogPrintf("NotifyTransactionChanged %s status=%i\n", hash.GetHex().c_str(), status);
|
||||
QMetaObject::invokeMethod(walletmodel, "updateTransaction", Qt::QueuedConnection,
|
||||
Q_ARG(QString, QString::fromStdString(hash.GetHex())),
|
||||
Q_ARG(int, status));
|
||||
|
@ -9,8 +9,6 @@
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#define printf OutputDebugStringF
|
||||
|
||||
using namespace json_spirit;
|
||||
using namespace std;
|
||||
|
||||
|
@ -251,7 +251,7 @@ Value getworkex(const Array& params, bool fHelp)
|
||||
Array merkle_arr;
|
||||
|
||||
BOOST_FOREACH(uint256 merkleh, merkle) {
|
||||
printf("%s\n", merkleh.ToString().c_str());
|
||||
LogPrintf("%s\n", merkleh.ToString().c_str());
|
||||
merkle_arr.push_back(HexStr(BEGIN(merkleh), END(merkleh)));
|
||||
}
|
||||
|
||||
|
@ -967,7 +967,7 @@ uint256 SignatureHash(CScript scriptCode, const CTransaction& txTo, unsigned int
|
||||
{
|
||||
if (nIn >= txTo.vin.size())
|
||||
{
|
||||
printf("ERROR: SignatureHash() : nIn=%d out of range\n", nIn);
|
||||
LogPrintf("ERROR: SignatureHash() : nIn=%d out of range\n", nIn);
|
||||
return 1;
|
||||
}
|
||||
CTransaction txTmp(txTo);
|
||||
@ -998,7 +998,7 @@ uint256 SignatureHash(CScript scriptCode, const CTransaction& txTo, unsigned int
|
||||
unsigned int nOut = nIn;
|
||||
if (nOut >= txTmp.vout.size())
|
||||
{
|
||||
printf("ERROR: SignatureHash() : nOut=%d out of range\n", nOut);
|
||||
LogPrintf("ERROR: SignatureHash() : nOut=%d out of range\n", nOut);
|
||||
return 1;
|
||||
}
|
||||
txTmp.vout.resize(nOut+1);
|
||||
@ -1980,4 +1980,4 @@ bool CScriptCompressor::Decompress(unsigned int nSize, const std::vector<unsigne
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -555,7 +555,7 @@ public:
|
||||
|
||||
void PrintHex() const
|
||||
{
|
||||
printf("CScript(%s)\n", HexStr(begin(), end(), true).c_str());
|
||||
LogPrintf("CScript(%s)\n", HexStr(begin(), end(), true).c_str());
|
||||
}
|
||||
|
||||
std::string ToString() const
|
||||
@ -583,7 +583,7 @@ public:
|
||||
|
||||
void print() const
|
||||
{
|
||||
printf("%s\n", ToString().c_str());
|
||||
LogPrintf("%s\n", ToString().c_str());
|
||||
}
|
||||
|
||||
CScriptID GetID() const
|
||||
@ -685,4 +685,4 @@ bool VerifyScript(const CScript& scriptSig, const CScript& scriptPubKey, const C
|
||||
// combine them intelligently and return the result.
|
||||
CScript CombineSignatures(CScript scriptPubKey, const CTransaction& txTo, unsigned int nIn, const CScript& scriptSig1, const CScript& scriptSig2);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
26
src/sync.cpp
26
src/sync.cpp
@ -10,8 +10,8 @@
|
||||
#ifdef DEBUG_LOCKCONTENTION
|
||||
void PrintLockContention(const char* pszName, const char* pszFile, int nLine)
|
||||
{
|
||||
printf("LOCKCONTENTION: %s\n", pszName);
|
||||
printf("Locker: %s:%d\n", pszFile, nLine);
|
||||
LogPrintf("LOCKCONTENTION: %s\n", pszName);
|
||||
LogPrintf("Locker: %s:%d\n", pszFile, nLine);
|
||||
}
|
||||
#endif /* DEBUG_LOCKCONTENTION */
|
||||
|
||||
@ -56,20 +56,20 @@ static boost::thread_specific_ptr<LockStack> lockstack;
|
||||
|
||||
static void potential_deadlock_detected(const std::pair<void*, void*>& mismatch, const LockStack& s1, const LockStack& s2)
|
||||
{
|
||||
printf("POTENTIAL DEADLOCK DETECTED\n");
|
||||
printf("Previous lock order was:\n");
|
||||
LogPrintf("POTENTIAL DEADLOCK DETECTED\n");
|
||||
LogPrintf("Previous lock order was:\n");
|
||||
BOOST_FOREACH(const PAIRTYPE(void*, CLockLocation)& i, s2)
|
||||
{
|
||||
if (i.first == mismatch.first) printf(" (1)");
|
||||
if (i.first == mismatch.second) printf(" (2)");
|
||||
printf(" %s\n", i.second.ToString().c_str());
|
||||
if (i.first == mismatch.first) LogPrintf(" (1)");
|
||||
if (i.first == mismatch.second) LogPrintf(" (2)");
|
||||
LogPrintf(" %s\n", i.second.ToString().c_str());
|
||||
}
|
||||
printf("Current lock order is:\n");
|
||||
LogPrintf("Current lock order is:\n");
|
||||
BOOST_FOREACH(const PAIRTYPE(void*, CLockLocation)& i, s1)
|
||||
{
|
||||
if (i.first == mismatch.first) printf(" (1)");
|
||||
if (i.first == mismatch.second) printf(" (2)");
|
||||
printf(" %s\n", i.second.ToString().c_str());
|
||||
if (i.first == mismatch.first) LogPrintf(" (1)");
|
||||
if (i.first == mismatch.second) LogPrintf(" (2)");
|
||||
LogPrintf(" %s\n", i.second.ToString().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@ -78,7 +78,7 @@ static void push_lock(void* c, const CLockLocation& locklocation, bool fTry)
|
||||
if (lockstack.get() == NULL)
|
||||
lockstack.reset(new LockStack);
|
||||
|
||||
if (fDebug) printf("Locking: %s\n", locklocation.ToString().c_str());
|
||||
if (fDebug) LogPrintf("Locking: %s\n", locklocation.ToString().c_str());
|
||||
dd_mutex.lock();
|
||||
|
||||
(*lockstack).push_back(std::make_pair(c, locklocation));
|
||||
@ -108,7 +108,7 @@ static void pop_lock()
|
||||
if (fDebug)
|
||||
{
|
||||
const CLockLocation& locklocation = (*lockstack).rbegin()->second;
|
||||
printf("Unlocked: %s\n", locklocation.ToString().c_str());
|
||||
LogPrintf("Unlocked: %s\n", locklocation.ToString().c_str());
|
||||
}
|
||||
dd_mutex.lock();
|
||||
(*lockstack).pop_back();
|
||||
|
@ -54,7 +54,7 @@ bool CCoinsViewDB::SetBestBlock(CBlockIndex *pindex) {
|
||||
}
|
||||
|
||||
bool CCoinsViewDB::BatchWrite(const std::map<uint256, CCoins> &mapCoins, CBlockIndex *pindex) {
|
||||
printf("Committing %u changed transactions to coin database...\n", (unsigned int)mapCoins.size());
|
||||
LogPrintf("Committing %u changed transactions to coin database...\n", (unsigned int)mapCoins.size());
|
||||
|
||||
CLevelDBBatch batch;
|
||||
for (std::map<uint256, CCoins>::const_iterator it = mapCoins.begin(); it != mapCoins.end(); it++)
|
||||
|
@ -772,39 +772,39 @@ inline int Testuint256AdHoc(std::vector<std::string> vArg)
|
||||
uint256 g(0);
|
||||
|
||||
|
||||
printf("%s\n", g.ToString().c_str());
|
||||
g--; printf("g--\n");
|
||||
printf("%s\n", g.ToString().c_str());
|
||||
g--; printf("g--\n");
|
||||
printf("%s\n", g.ToString().c_str());
|
||||
g++; printf("g++\n");
|
||||
printf("%s\n", g.ToString().c_str());
|
||||
g++; printf("g++\n");
|
||||
printf("%s\n", g.ToString().c_str());
|
||||
g++; printf("g++\n");
|
||||
printf("%s\n", g.ToString().c_str());
|
||||
g++; printf("g++\n");
|
||||
printf("%s\n", g.ToString().c_str());
|
||||
LogPrintf("%s\n", g.ToString().c_str());
|
||||
g--; LogPrintf("g--\n");
|
||||
LogPrintf("%s\n", g.ToString().c_str());
|
||||
g--; LogPrintf("g--\n");
|
||||
LogPrintf("%s\n", g.ToString().c_str());
|
||||
g++; LogPrintf("g++\n");
|
||||
LogPrintf("%s\n", g.ToString().c_str());
|
||||
g++; LogPrintf("g++\n");
|
||||
LogPrintf("%s\n", g.ToString().c_str());
|
||||
g++; LogPrintf("g++\n");
|
||||
LogPrintf("%s\n", g.ToString().c_str());
|
||||
g++; LogPrintf("g++\n");
|
||||
LogPrintf("%s\n", g.ToString().c_str());
|
||||
|
||||
|
||||
|
||||
uint256 a(7);
|
||||
printf("a=7\n");
|
||||
printf("%s\n", a.ToString().c_str());
|
||||
LogPrintf("a=7\n");
|
||||
LogPrintf("%s\n", a.ToString().c_str());
|
||||
|
||||
uint256 b;
|
||||
printf("b undefined\n");
|
||||
printf("%s\n", b.ToString().c_str());
|
||||
LogPrintf("b undefined\n");
|
||||
LogPrintf("%s\n", b.ToString().c_str());
|
||||
int c = 3;
|
||||
|
||||
a = c;
|
||||
a.pn[3] = 15;
|
||||
printf("%s\n", a.ToString().c_str());
|
||||
LogPrintf("%s\n", a.ToString().c_str());
|
||||
uint256 k(c);
|
||||
|
||||
a = 5;
|
||||
a.pn[3] = 15;
|
||||
printf("%s\n", a.ToString().c_str());
|
||||
LogPrintf("%s\n", a.ToString().c_str());
|
||||
b = 1;
|
||||
b <<= 52;
|
||||
|
||||
@ -812,86 +812,86 @@ inline int Testuint256AdHoc(std::vector<std::string> vArg)
|
||||
|
||||
a ^= 0x500;
|
||||
|
||||
printf("a %s\n", a.ToString().c_str());
|
||||
LogPrintf("a %s\n", a.ToString().c_str());
|
||||
|
||||
a = a | b | (uint256)0x1000;
|
||||
|
||||
|
||||
printf("a %s\n", a.ToString().c_str());
|
||||
printf("b %s\n", b.ToString().c_str());
|
||||
LogPrintf("a %s\n", a.ToString().c_str());
|
||||
LogPrintf("b %s\n", b.ToString().c_str());
|
||||
|
||||
a = 0xfffffffe;
|
||||
a.pn[4] = 9;
|
||||
|
||||
printf("%s\n", a.ToString().c_str());
|
||||
LogPrintf("%s\n", a.ToString().c_str());
|
||||
a++;
|
||||
printf("%s\n", a.ToString().c_str());
|
||||
LogPrintf("%s\n", a.ToString().c_str());
|
||||
a++;
|
||||
printf("%s\n", a.ToString().c_str());
|
||||
LogPrintf("%s\n", a.ToString().c_str());
|
||||
a++;
|
||||
printf("%s\n", a.ToString().c_str());
|
||||
LogPrintf("%s\n", a.ToString().c_str());
|
||||
a++;
|
||||
printf("%s\n", a.ToString().c_str());
|
||||
LogPrintf("%s\n", a.ToString().c_str());
|
||||
|
||||
a--;
|
||||
printf("%s\n", a.ToString().c_str());
|
||||
LogPrintf("%s\n", a.ToString().c_str());
|
||||
a--;
|
||||
printf("%s\n", a.ToString().c_str());
|
||||
LogPrintf("%s\n", a.ToString().c_str());
|
||||
a--;
|
||||
printf("%s\n", a.ToString().c_str());
|
||||
LogPrintf("%s\n", a.ToString().c_str());
|
||||
uint256 d = a--;
|
||||
printf("%s\n", d.ToString().c_str());
|
||||
printf("%s\n", a.ToString().c_str());
|
||||
LogPrintf("%s\n", d.ToString().c_str());
|
||||
LogPrintf("%s\n", a.ToString().c_str());
|
||||
a--;
|
||||
printf("%s\n", a.ToString().c_str());
|
||||
LogPrintf("%s\n", a.ToString().c_str());
|
||||
a--;
|
||||
printf("%s\n", a.ToString().c_str());
|
||||
LogPrintf("%s\n", a.ToString().c_str());
|
||||
|
||||
d = a;
|
||||
|
||||
printf("%s\n", d.ToString().c_str());
|
||||
for (int i = uint256::WIDTH-1; i >= 0; i--) printf("%08x", d.pn[i]); printf("\n");
|
||||
LogPrintf("%s\n", d.ToString().c_str());
|
||||
for (int i = uint256::WIDTH-1; i >= 0; i--) LogPrintf("%08x", d.pn[i]); LogPrintf("\n");
|
||||
|
||||
uint256 neg = d;
|
||||
neg = ~neg;
|
||||
printf("%s\n", neg.ToString().c_str());
|
||||
LogPrintf("%s\n", neg.ToString().c_str());
|
||||
|
||||
|
||||
uint256 e = uint256("0xABCDEF123abcdef12345678909832180000011111111");
|
||||
printf("\n");
|
||||
printf("%s\n", e.ToString().c_str());
|
||||
LogPrintf("\n");
|
||||
LogPrintf("%s\n", e.ToString().c_str());
|
||||
|
||||
|
||||
printf("\n");
|
||||
LogPrintf("\n");
|
||||
uint256 x1 = uint256("0xABCDEF123abcdef12345678909832180000011111111");
|
||||
uint256 x2;
|
||||
printf("%s\n", x1.ToString().c_str());
|
||||
LogPrintf("%s\n", x1.ToString().c_str());
|
||||
for (int i = 0; i < 270; i += 4)
|
||||
{
|
||||
x2 = x1 << i;
|
||||
printf("%s\n", x2.ToString().c_str());
|
||||
LogPrintf("%s\n", x2.ToString().c_str());
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
printf("%s\n", x1.ToString().c_str());
|
||||
LogPrintf("\n");
|
||||
LogPrintf("%s\n", x1.ToString().c_str());
|
||||
for (int i = 0; i < 270; i += 4)
|
||||
{
|
||||
x2 = x1;
|
||||
x2 >>= i;
|
||||
printf("%s\n", x2.ToString().c_str());
|
||||
LogPrintf("%s\n", x2.ToString().c_str());
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
uint256 k = (~uint256(0) >> i);
|
||||
printf("%s\n", k.ToString().c_str());
|
||||
LogPrintf("%s\n", k.ToString().c_str());
|
||||
}
|
||||
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
uint256 k = (~uint256(0) << i);
|
||||
printf("%s\n", k.ToString().c_str());
|
||||
LogPrintf("%s\n", k.ToString().c_str());
|
||||
}
|
||||
|
||||
return (0);
|
||||
|
41
src/util.cpp
41
src/util.cpp
@ -167,7 +167,7 @@ void RandAddSeedPerfmon()
|
||||
{
|
||||
RAND_add(pdata, nSize, nSize/100.0);
|
||||
OPENSSL_cleanse(pdata, nSize);
|
||||
printf("RandAddSeed() %lu bytes\n", nSize);
|
||||
LogPrintf("RandAddSeed() %lu bytes\n", nSize);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -206,8 +206,7 @@ uint256 GetRandHash()
|
||||
|
||||
|
||||
//
|
||||
// OutputDebugStringF (aka printf -- there is a #define that we really
|
||||
// should get rid of one day) has been broken a couple of times now
|
||||
// LogPrintf() has been broken a couple of times now
|
||||
// by well-meaning people adding mutexes in the most straightforward way.
|
||||
// It breaks because it may be called by global destructors during shutdown.
|
||||
// Since the order of destruction of static/global objects is undefined,
|
||||
@ -234,8 +233,14 @@ static void DebugPrintInit()
|
||||
mutexDebugLog = new boost::mutex();
|
||||
}
|
||||
|
||||
int OutputDebugStringF(const char* pszFormat, ...)
|
||||
int LogPrint(const char* category, const char* pszFormat, ...)
|
||||
{
|
||||
if (category != NULL) {
|
||||
const vector<string>& categories = mapMultiArgs["-debug"];
|
||||
if (find(categories.begin(), categories.end(), string(category)) == categories.end())
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ret = 0; // Returns total number of characters written
|
||||
if (fPrintToConsole)
|
||||
{
|
||||
@ -361,7 +366,7 @@ bool error(const char *format, ...)
|
||||
va_start(arg_ptr, format);
|
||||
std::string str = vstrprintf(format, arg_ptr);
|
||||
va_end(arg_ptr);
|
||||
printf("ERROR: %s\n", str.c_str());
|
||||
LogPrintf("ERROR: %s\n", str.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1008,13 +1013,13 @@ static std::string FormatException(std::exception* pex, const char* pszThread)
|
||||
void LogException(std::exception* pex, const char* pszThread)
|
||||
{
|
||||
std::string message = FormatException(pex, pszThread);
|
||||
printf("\n%s", message.c_str());
|
||||
LogPrintf("\n%s", message.c_str());
|
||||
}
|
||||
|
||||
void PrintException(std::exception* pex, const char* pszThread)
|
||||
{
|
||||
std::string message = FormatException(pex, pszThread);
|
||||
printf("\n\n************************\n%s\n", message.c_str());
|
||||
LogPrintf("\n\n************************\n%s\n", message.c_str());
|
||||
fprintf(stderr, "\n\n************************\n%s\n", message.c_str());
|
||||
strMiscWarning = message;
|
||||
throw;
|
||||
@ -1023,7 +1028,7 @@ void PrintException(std::exception* pex, const char* pszThread)
|
||||
void PrintExceptionContinue(std::exception* pex, const char* pszThread)
|
||||
{
|
||||
std::string message = FormatException(pex, pszThread);
|
||||
printf("\n\n************************\n%s\n", message.c_str());
|
||||
LogPrintf("\n\n************************\n%s\n", message.c_str());
|
||||
fprintf(stderr, "\n\n************************\n%s\n", message.c_str());
|
||||
strMiscWarning = message;
|
||||
}
|
||||
@ -1066,7 +1071,7 @@ const boost::filesystem::path &GetDataDir(bool fNetSpecific)
|
||||
|
||||
fs::path &path = pathCached[fNetSpecific];
|
||||
|
||||
// This can be called during exceptions by printf, so we cache the
|
||||
// This can be called during exceptions by LogPrintf(), so we cache the
|
||||
// value so we don't have to do memory allocations after that.
|
||||
if (fCachedPath[fNetSpecific])
|
||||
return path;
|
||||
@ -1330,7 +1335,7 @@ void AddTimeData(const CNetAddr& ip, int64 nTime)
|
||||
|
||||
// Add data
|
||||
vTimeOffsets.input(nOffsetSample);
|
||||
printf("Added time data, samples %d, offset %+"PRI64d" (%+"PRI64d" minutes)\n", vTimeOffsets.size(), nOffsetSample, nOffsetSample/60);
|
||||
LogPrintf("Added time data, samples %d, offset %+"PRI64d" (%+"PRI64d" minutes)\n", vTimeOffsets.size(), nOffsetSample, nOffsetSample/60);
|
||||
if (vTimeOffsets.size() >= 5 && vTimeOffsets.size() % 2 == 1)
|
||||
{
|
||||
int64 nMedian = vTimeOffsets.median();
|
||||
@ -1358,17 +1363,17 @@ void AddTimeData(const CNetAddr& ip, int64 nTime)
|
||||
fDone = true;
|
||||
string strMessage = _("Warning: Please check that your computer's date and time are correct! If your clock is wrong DarkCoin will not work properly.");
|
||||
strMiscWarning = strMessage;
|
||||
printf("*** %s\n", strMessage.c_str());
|
||||
LogPrintf("*** %s\n", strMessage.c_str());
|
||||
uiInterface.ThreadSafeMessageBox(strMessage, "", CClientUIInterface::MSG_WARNING);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (fDebug) {
|
||||
BOOST_FOREACH(int64 n, vSorted)
|
||||
printf("%+"PRI64d" ", n);
|
||||
printf("| ");
|
||||
LogPrintf("%+"PRI64d" ", n);
|
||||
LogPrintf("| ");
|
||||
}
|
||||
printf("nTimeOffset = %+"PRI64d" (%+"PRI64d" minutes)\n", nTimeOffset, nTimeOffset/60);
|
||||
LogPrintf("nTimeOffset = %+"PRI64d" (%+"PRI64d" minutes)\n", nTimeOffset, nTimeOffset/60);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1430,7 +1435,7 @@ boost::filesystem::path GetSpecialFolderPath(int nFolder, bool fCreate)
|
||||
return fs::path(pszPath);
|
||||
}
|
||||
|
||||
printf("SHGetSpecialFolderPathA() failed, could not obtain requested path.\n");
|
||||
LogPrintf("SHGetSpecialFolderPathA() failed, could not obtain requested path.\n");
|
||||
return fs::path("");
|
||||
}
|
||||
#endif
|
||||
@ -1450,7 +1455,7 @@ boost::filesystem::path GetTempPath() {
|
||||
path = boost::filesystem::path("/tmp");
|
||||
#endif
|
||||
if (path.empty() || !boost::filesystem::is_directory(path)) {
|
||||
printf("GetTempPath(): failed to find temp path\n");
|
||||
LogPrintf("GetTempPath(): failed to find temp path\n");
|
||||
return boost::filesystem::path("");
|
||||
}
|
||||
return path;
|
||||
@ -1461,7 +1466,7 @@ void runCommand(std::string strCommand)
|
||||
{
|
||||
int nErr = ::system(strCommand.c_str());
|
||||
if (nErr)
|
||||
printf("runCommand error: system(%s) returned %d\n", strCommand.c_str(), nErr);
|
||||
LogPrintf("runCommand error: system(%s) returned %d\n", strCommand.c_str(), nErr);
|
||||
}
|
||||
|
||||
void RenameThread(const char* name)
|
||||
@ -1494,7 +1499,7 @@ bool NewThread(void(*pfn)(void*), void* parg)
|
||||
{
|
||||
boost::thread(pfn, parg); // thread detaches when out of scope
|
||||
} catch(boost::thread_resource_error &e) {
|
||||
printf("Error creating thread: %s\n", e.what());
|
||||
LogPrintf("Error creating thread: %s\n", e.what());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
27
src/util.h
27
src/util.h
@ -151,7 +151,10 @@ extern volatile bool fReopenDebugLog;
|
||||
|
||||
void RandAddSeed();
|
||||
void RandAddSeedPerfmon();
|
||||
int ATTR_WARN_PRINTF(1,2) OutputDebugStringF(const char* pszFormat, ...);
|
||||
|
||||
// Print to debug.log if -debug=category switch is given OR category is NULL.
|
||||
int ATTR_WARN_PRINTF(2,3) LogPrint(const char* category, const char* pszFormat, ...);
|
||||
#define LogPrintf(...) LogPrint(NULL, __VA_ARGS__)
|
||||
|
||||
/*
|
||||
Rationale for the real_strprintf / strprintf construction:
|
||||
@ -171,14 +174,6 @@ std::string vstrprintf(const char *format, va_list ap);
|
||||
|
||||
bool ATTR_WARN_PRINTF(1,2) error(const char *format, ...);
|
||||
|
||||
/* Redefine printf so that it directs output to debug.log
|
||||
*
|
||||
* Do this *after* defining the other printf-like functions, because otherwise the
|
||||
* __attribute__((format(printf,X,Y))) gets expanded to __attribute__((format(OutputDebugStringF,X,Y)))
|
||||
* which confuses gcc.
|
||||
*/
|
||||
#define printf OutputDebugStringF
|
||||
|
||||
void LogException(std::exception* pex, const char* pszThread);
|
||||
void PrintException(std::exception* pex, const char* pszThread);
|
||||
void PrintExceptionContinue(std::exception* pex, const char* pszThread);
|
||||
@ -316,12 +311,12 @@ inline std::string HexStr(const T& vch, bool fSpaces=false)
|
||||
template<typename T>
|
||||
void PrintHex(const T pbegin, const T pend, const char* pszFormat="%s", bool fSpaces=true)
|
||||
{
|
||||
printf(pszFormat, HexStr(pbegin, pend, fSpaces).c_str());
|
||||
LogPrintf(pszFormat, HexStr(pbegin, pend, fSpaces).c_str());
|
||||
}
|
||||
|
||||
inline void PrintHex(const std::vector<unsigned char>& vch, const char* pszFormat="%s", bool fSpaces=true)
|
||||
{
|
||||
printf(pszFormat, HexStr(vch, fSpaces).c_str());
|
||||
LogPrintf(pszFormat, HexStr(vch, fSpaces).c_str());
|
||||
}
|
||||
|
||||
inline int64 GetPerformanceCounter()
|
||||
@ -562,7 +557,7 @@ template <typename Callable> void LoopForever(const char* name, Callable func,
|
||||
{
|
||||
std::string s = strprintf("bitcoin-%s", name);
|
||||
RenameThread(s.c_str());
|
||||
printf("%s thread start\n", name);
|
||||
LogPrintf("%s thread start\n", name);
|
||||
try
|
||||
{
|
||||
while (1)
|
||||
@ -573,7 +568,7 @@ template <typename Callable> void LoopForever(const char* name, Callable func,
|
||||
}
|
||||
catch (boost::thread_interrupted)
|
||||
{
|
||||
printf("%s thread stop\n", name);
|
||||
LogPrintf("%s thread stop\n", name);
|
||||
throw;
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
@ -590,13 +585,13 @@ template <typename Callable> void TraceThread(const char* name, Callable func)
|
||||
RenameThread(s.c_str());
|
||||
try
|
||||
{
|
||||
printf("%s thread start\n", name);
|
||||
LogPrintf("%s thread start\n", name);
|
||||
func();
|
||||
printf("%s thread exit\n", name);
|
||||
LogPrintf("%s thread exit\n", name);
|
||||
}
|
||||
catch (boost::thread_interrupted)
|
||||
{
|
||||
printf("%s thread interrupt\n", name);
|
||||
LogPrintf("%s thread interrupt\n", name);
|
||||
throw;
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
|
@ -140,7 +140,7 @@ bool CWallet::ChangeWalletPassphrase(const SecureString& strOldWalletPassphrase,
|
||||
if (pMasterKey.second.nDeriveIterations < 25000)
|
||||
pMasterKey.second.nDeriveIterations = 25000;
|
||||
|
||||
printf("Wallet passphrase changed to an nDeriveIterations of %i\n", pMasterKey.second.nDeriveIterations);
|
||||
LogPrintf("Wallet passphrase changed to an nDeriveIterations of %i\n", pMasterKey.second.nDeriveIterations);
|
||||
|
||||
if (!crypter.SetKeyFromPassphrase(strNewWalletPassphrase, pMasterKey.second.vchSalt, pMasterKey.second.nDeriveIterations, pMasterKey.second.nDerivationMethod))
|
||||
return false;
|
||||
@ -248,7 +248,7 @@ bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase)
|
||||
if (kMasterKey.nDeriveIterations < 25000)
|
||||
kMasterKey.nDeriveIterations = 25000;
|
||||
|
||||
printf("Encrypting Wallet with an nDeriveIterations of %i\n", kMasterKey.nDeriveIterations);
|
||||
LogPrintf("Encrypting Wallet with an nDeriveIterations of %i\n", kMasterKey.nDeriveIterations);
|
||||
|
||||
if (!crypter.SetKeyFromPassphrase(strWalletPassphrase, kMasterKey.vchSalt, kMasterKey.nDeriveIterations, kMasterKey.nDerivationMethod))
|
||||
return false;
|
||||
@ -349,10 +349,10 @@ void CWallet::WalletUpdateSpent(const CTransaction &tx)
|
||||
{
|
||||
CWalletTx& wtx = (*mi).second;
|
||||
if (txin.prevout.n >= wtx.vout.size())
|
||||
printf("WalletUpdateSpent: bad wtx %s\n", wtx.GetHash().ToString().c_str());
|
||||
LogPrintf("WalletUpdateSpent: bad wtx %s\n", wtx.GetHash().ToString().c_str());
|
||||
else if (!wtx.IsSpent(txin.prevout.n) && IsMine(wtx.vout[txin.prevout.n]))
|
||||
{
|
||||
printf("WalletUpdateSpent found spent coin %sbc %s\n", FormatMoney(wtx.GetCredit()).c_str(), wtx.GetHash().ToString().c_str());
|
||||
LogPrintf("WalletUpdateSpent found spent coin %sbc %s\n", FormatMoney(wtx.GetCredit()).c_str(), wtx.GetHash().ToString().c_str());
|
||||
wtx.MarkSpent(txin.prevout.n);
|
||||
wtx.WriteToDisk();
|
||||
NotifyTransactionChanged(this, txin.prevout.hash, CT_UPDATED);
|
||||
@ -427,7 +427,7 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn)
|
||||
wtx.nTimeSmart = std::max(latestEntry, std::min(blocktime, latestNow));
|
||||
}
|
||||
else
|
||||
printf("AddToWallet() : found %s in block %s not in index\n",
|
||||
LogPrintf("AddToWallet() : found %s in block %s not in index\n",
|
||||
wtxIn.GetHash().ToString().c_str(),
|
||||
wtxIn.hashBlock.ToString().c_str());
|
||||
}
|
||||
@ -457,7 +457,7 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn)
|
||||
}
|
||||
|
||||
//// debug print
|
||||
printf("AddToWallet %s %s%s\n", wtxIn.GetHash().ToString().c_str(), (fInsertedNew ? "new" : ""), (fUpdated ? "update" : ""));
|
||||
LogPrintf("AddToWallet %s %s%s\n", wtxIn.GetHash().ToString().c_str(), (fInsertedNew ? "new" : ""), (fUpdated ? "update" : ""));
|
||||
|
||||
// Write to disk
|
||||
if (fInsertedNew || fUpdated)
|
||||
@ -657,7 +657,7 @@ void CWalletTx::GetAmounts(list<pair<CTxDestination, int64> >& listReceived,
|
||||
vector<unsigned char> vchPubKey;
|
||||
if (!ExtractDestination(txout.scriptPubKey, address))
|
||||
{
|
||||
printf("CWalletTx::GetAmounts: Unknown transaction type found, txid %s\n",
|
||||
LogPrintf("CWalletTx::GetAmounts: Unknown transaction type found, txid %s\n",
|
||||
this->GetHash().ToString().c_str());
|
||||
}
|
||||
|
||||
@ -826,7 +826,7 @@ void CWallet::ReacceptWalletTransactions()
|
||||
}
|
||||
if (fUpdated)
|
||||
{
|
||||
printf("ReacceptWalletTransactions found spent coin %sbc %s\n", FormatMoney(wtx.GetCredit()).c_str(), wtx.GetHash().ToString().c_str());
|
||||
LogPrintf("ReacceptWalletTransactions found spent coin %sbc %s\n", FormatMoney(wtx.GetCredit()).c_str(), wtx.GetHash().ToString().c_str());
|
||||
wtx.MarkDirty();
|
||||
wtx.WriteToDisk();
|
||||
}
|
||||
@ -862,7 +862,7 @@ void CWalletTx::RelayWalletTransaction()
|
||||
{
|
||||
if (GetDepthInMainChain() == 0) {
|
||||
uint256 hash = GetHash();
|
||||
printf("Relaying wtx %s\n", hash.ToString().c_str());
|
||||
LogPrintf("Relaying wtx %s\n", hash.ToString().c_str());
|
||||
RelayTransaction((CTransaction)*this, hash);
|
||||
}
|
||||
}
|
||||
@ -887,7 +887,7 @@ void CWallet::ResendWalletTransactions()
|
||||
nLastTime = GetTime();
|
||||
|
||||
// Rebroadcast any of our txes that aren't in a block yet
|
||||
printf("ResendWalletTransactions()\n");
|
||||
LogPrintf("ResendWalletTransactions()\n");
|
||||
{
|
||||
LOCK(cs_wallet);
|
||||
// Sort them in chronological order
|
||||
@ -1129,11 +1129,11 @@ bool CWallet::SelectCoinsMinConf(int64 nTargetValue, int nConfMine, int nConfThe
|
||||
}
|
||||
|
||||
//// debug print
|
||||
printf("SelectCoins() best subset: ");
|
||||
LogPrintf("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());
|
||||
LogPrintf("%s ", FormatMoney(vValue[i].first).c_str());
|
||||
LogPrintf("total %s\n", FormatMoney(nBest).c_str());
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -1339,7 +1339,7 @@ bool CWallet::CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey)
|
||||
{
|
||||
{
|
||||
LOCK2(cs_main, cs_wallet);
|
||||
printf("CommitTransaction:\n%s", wtxNew.ToString().c_str());
|
||||
LogPrintf("CommitTransaction:\n%s", wtxNew.ToString().c_str());
|
||||
{
|
||||
// This is only to keep the database open to defeat the auto-flush for the
|
||||
// duration of this scope. This is the only place where this optimization
|
||||
@ -1375,7 +1375,7 @@ bool CWallet::CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey)
|
||||
if (!wtxNew.AcceptToMemoryPool(true, false))
|
||||
{
|
||||
// This must not fail. The transaction has already been signed and recorded.
|
||||
printf("CommitTransaction() : Error: Transaction not valid");
|
||||
LogPrintf("CommitTransaction() : Error: Transaction not valid");
|
||||
return false;
|
||||
}
|
||||
wtxNew.RelayWalletTransaction();
|
||||
@ -1394,7 +1394,7 @@ string CWallet::SendMoney(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew,
|
||||
if (IsLocked())
|
||||
{
|
||||
string strError = _("Error: Wallet locked, unable to create transaction!");
|
||||
printf("SendMoney() : %s", strError.c_str());
|
||||
LogPrintf("SendMoney() : %s", strError.c_str());
|
||||
return strError;
|
||||
}
|
||||
string strError;
|
||||
@ -1402,7 +1402,7 @@ string CWallet::SendMoney(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew,
|
||||
{
|
||||
if (nValue + nFeeRequired > GetBalance())
|
||||
strError = strprintf(_("Error: This transaction requires a transaction fee of at least %s because of its amount, complexity, or use of recently received funds!"), FormatMoney(nFeeRequired).c_str());
|
||||
printf("SendMoney() : %s\n", strError.c_str());
|
||||
LogPrintf("SendMoney() : %s\n", strError.c_str());
|
||||
return strError;
|
||||
}
|
||||
|
||||
@ -1487,10 +1487,10 @@ void CWallet::PrintWallet(const CBlock& block)
|
||||
if (mapWallet.count(block.vtx[0].GetHash()))
|
||||
{
|
||||
CWalletTx& wtx = mapWallet[block.vtx[0].GetHash()];
|
||||
printf(" mine: %d %d %"PRI64d"", wtx.GetDepthInMainChain(), wtx.GetBlocksToMaturity(), wtx.GetCredit());
|
||||
LogPrintf(" mine: %d %d %"PRI64d"", wtx.GetDepthInMainChain(), wtx.GetBlocksToMaturity(), wtx.GetCredit());
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
LogPrintf("\n");
|
||||
}
|
||||
|
||||
bool CWallet::GetTransaction(const uint256 &hashTx, CWalletTx& wtx)
|
||||
@ -1549,7 +1549,7 @@ bool CWallet::NewKeyPool()
|
||||
walletdb.WritePool(nIndex, CKeyPool(GenerateNewKey()));
|
||||
setKeyPool.insert(nIndex);
|
||||
}
|
||||
printf("CWallet::NewKeyPool wrote %"PRI64d" new keys\n", nKeys);
|
||||
LogPrintf("CWallet::NewKeyPool wrote %"PRI64d" new keys\n", nKeys);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -1574,7 +1574,7 @@ bool CWallet::TopUpKeyPool()
|
||||
if (!walletdb.WritePool(nEnd, CKeyPool(GenerateNewKey())))
|
||||
throw runtime_error("TopUpKeyPool() : writing generated key failed");
|
||||
setKeyPool.insert(nEnd);
|
||||
printf("keypool added key %"PRI64d", size=%"PRIszu"\n", nEnd, setKeyPool.size());
|
||||
LogPrintf("keypool added key %"PRI64d", size=%"PRIszu"\n", nEnd, setKeyPool.size());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@ -1603,7 +1603,7 @@ void CWallet::ReserveKeyFromKeyPool(int64& nIndex, CKeyPool& keypool)
|
||||
if (!HaveKey(keypool.vchPubKey.GetID()))
|
||||
throw runtime_error("ReserveKeyFromKeyPool() : unknown key in key pool");
|
||||
assert(keypool.vchPubKey.IsValid());
|
||||
printf("keypool reserve %"PRI64d"\n", nIndex);
|
||||
LogPrintf("keypool reserve %"PRI64d"\n", nIndex);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1630,7 +1630,7 @@ void CWallet::KeepKey(int64 nIndex)
|
||||
CWalletDB walletdb(strWalletFile);
|
||||
walletdb.ErasePool(nIndex);
|
||||
}
|
||||
printf("keypool keep %"PRI64d"\n", nIndex);
|
||||
LogPrintf("keypool keep %"PRI64d"\n", nIndex);
|
||||
}
|
||||
|
||||
void CWallet::ReturnKey(int64 nIndex)
|
||||
@ -1640,7 +1640,7 @@ void CWallet::ReturnKey(int64 nIndex)
|
||||
LOCK(cs_wallet);
|
||||
setKeyPool.insert(nIndex);
|
||||
}
|
||||
printf("keypool return %"PRI64d"\n", nIndex);
|
||||
LogPrintf("keypool return %"PRI64d"\n", nIndex);
|
||||
}
|
||||
|
||||
bool CWallet::GetKeyFromPool(CPubKey& result, bool fAllowReuse)
|
||||
@ -1820,7 +1820,7 @@ bool CReserveKey::GetReservedKey(CPubKey& pubkey)
|
||||
vchPubKey = keypool.vchPubKey;
|
||||
else {
|
||||
if (pwallet->vchDefaultKey.IsValid()) {
|
||||
printf("CReserveKey::GetReservedKey(): Warning: Using default key instead of a new key, top up your keypool!");
|
||||
LogPrintf("CReserveKey::GetReservedKey(): Warning: Using default key instead of a new key, top up your keypool!");
|
||||
vchPubKey = pwallet->vchDefaultKey;
|
||||
} else
|
||||
return false;
|
||||
|
@ -712,7 +712,7 @@ public:
|
||||
|
||||
void print() const
|
||||
{
|
||||
printf("%s\n", ToString().c_str());
|
||||
LogPrintf("%s\n", ToString().c_str());
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -237,8 +237,8 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue,
|
||||
fAnyUnordered = true;
|
||||
|
||||
//// debug print
|
||||
//printf("LoadWallet %s\n", wtx.GetHash().ToString().c_str());
|
||||
//printf(" %12"PRI64d" %s %s %s\n",
|
||||
//LogPrintf("LoadWallet %s\n", wtx.GetHash().ToString().c_str());
|
||||
//LogPrintf(" %12"PRI64d" %s %s %s\n",
|
||||
// wtx.vout[0].nValue,
|
||||
// DateTimeStrFormat("%Y-%m-%d %H:%M:%S", wtx.GetBlockTime()).c_str(),
|
||||
// wtx.hashBlock.ToString().c_str(),
|
||||
@ -392,7 +392,7 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet)
|
||||
Dbc* pcursor = GetCursor();
|
||||
if (!pcursor)
|
||||
{
|
||||
printf("Error getting wallet database cursor\n");
|
||||
LogPrintf("Error getting wallet database cursor\n");
|
||||
return DB_CORRUPT;
|
||||
}
|
||||
|
||||
@ -406,7 +406,7 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet)
|
||||
break;
|
||||
else if (ret != 0)
|
||||
{
|
||||
printf("Error reading next record from wallet database\n");
|
||||
LogPrintf("Error reading next record from wallet database\n");
|
||||
return DB_CORRUPT;
|
||||
}
|
||||
|
||||
@ -429,7 +429,7 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet)
|
||||
}
|
||||
}
|
||||
if (!strErr.empty())
|
||||
printf("%s\n", strErr.c_str());
|
||||
LogPrintf("%s\n", strErr.c_str());
|
||||
}
|
||||
pcursor->close();
|
||||
}
|
||||
@ -448,7 +448,7 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet)
|
||||
if (result != DB_LOAD_OK)
|
||||
return result;
|
||||
|
||||
printf("nFileVersion = %d\n", nFileVersion);
|
||||
LogPrintf("nFileVersion = %d\n", nFileVersion);
|
||||
|
||||
BOOST_FOREACH(uint256 hash, vWalletUpgrade)
|
||||
WriteTx(hash, pwallet->mapWallet[hash]);
|
||||
@ -511,7 +511,7 @@ void ThreadFlushWalletDB(const string& strFile)
|
||||
map<string, int>::iterator mi = bitdb.mapFileUseCount.find(strFile);
|
||||
if (mi != bitdb.mapFileUseCount.end())
|
||||
{
|
||||
printf("Flushing wallet.dat\n");
|
||||
LogPrintf("Flushing wallet.dat\n");
|
||||
nLastFlushed = nWalletDBUpdated;
|
||||
int64 nStart = GetTimeMillis();
|
||||
|
||||
@ -520,7 +520,7 @@ void ThreadFlushWalletDB(const string& strFile)
|
||||
bitdb.CheckpointLSN(strFile);
|
||||
|
||||
bitdb.mapFileUseCount.erase(mi++);
|
||||
printf("Flushed wallet.dat %"PRI64d"ms\n", GetTimeMillis() - nStart);
|
||||
LogPrintf("Flushed wallet.dat %"PRI64d"ms\n", GetTimeMillis() - nStart);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -555,10 +555,10 @@ bool BackupWallet(const CWallet& wallet, const string& strDest)
|
||||
#else
|
||||
filesystem::copy_file(pathSrc, pathDest);
|
||||
#endif
|
||||
printf("copied wallet.dat to %s\n", pathDest.string().c_str());
|
||||
LogPrintf("copied wallet.dat to %s\n", pathDest.string().c_str());
|
||||
return true;
|
||||
} catch(const filesystem::filesystem_error &e) {
|
||||
printf("error copying wallet.dat to %s - %s\n", pathDest.string().c_str(), e.what());
|
||||
LogPrintf("error copying wallet.dat to %s - %s\n", pathDest.string().c_str(), e.what());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -586,10 +586,10 @@ bool CWalletDB::Recover(CDBEnv& dbenv, std::string filename, bool fOnlyKeys)
|
||||
int result = dbenv.dbenv.dbrename(NULL, filename.c_str(), NULL,
|
||||
newFilename.c_str(), DB_AUTO_COMMIT);
|
||||
if (result == 0)
|
||||
printf("Renamed %s to %s\n", filename.c_str(), newFilename.c_str());
|
||||
LogPrintf("Renamed %s to %s\n", filename.c_str(), newFilename.c_str());
|
||||
else
|
||||
{
|
||||
printf("Failed to rename %s to %s\n", filename.c_str(), newFilename.c_str());
|
||||
LogPrintf("Failed to rename %s to %s\n", filename.c_str(), newFilename.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -597,10 +597,10 @@ bool CWalletDB::Recover(CDBEnv& dbenv, std::string filename, bool fOnlyKeys)
|
||||
bool allOK = dbenv.Salvage(newFilename, true, salvagedData);
|
||||
if (salvagedData.empty())
|
||||
{
|
||||
printf("Salvage(aggressive) found no records in %s.\n", newFilename.c_str());
|
||||
LogPrintf("Salvage(aggressive) found no records in %s.\n", newFilename.c_str());
|
||||
return false;
|
||||
}
|
||||
printf("Salvage(aggressive) found %"PRIszu" records\n", salvagedData.size());
|
||||
LogPrintf("Salvage(aggressive) found %"PRIszu" records\n", salvagedData.size());
|
||||
|
||||
bool fSuccess = allOK;
|
||||
Db* pdbCopy = new Db(&dbenv.dbenv, 0);
|
||||
@ -612,7 +612,7 @@ bool CWalletDB::Recover(CDBEnv& dbenv, std::string filename, bool fOnlyKeys)
|
||||
0);
|
||||
if (ret > 0)
|
||||
{
|
||||
printf("Cannot create database file %s\n", filename.c_str());
|
||||
LogPrintf("Cannot create database file %s\n", filename.c_str());
|
||||
return false;
|
||||
}
|
||||
CWallet dummyWallet;
|
||||
@ -637,7 +637,7 @@ bool CWalletDB::Recover(CDBEnv& dbenv, std::string filename, bool fOnlyKeys)
|
||||
continue;
|
||||
if (!fReadOK)
|
||||
{
|
||||
printf("WARNING: CWalletDB::Recover skipping %s: %s\n", strType.c_str(), strErr.c_str());
|
||||
LogPrintf("WARNING: CWalletDB::Recover skipping %s: %s\n", strType.c_str(), strErr.c_str());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user