Skip to content

Instantly share code, notes, and snippets.

@polarbeard
Created February 1, 2016 13:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save polarbeard/38b7835cb5f7863d4547 to your computer and use it in GitHub Desktop.
Save polarbeard/38b7835cb5f7863d4547 to your computer and use it in GitHub Desktop.
diff -uNr a/bitcoin/src/bitcoinrpc.cpp b/bitcoin/src/bitcoinrpc.cpp
--- a/bitcoin/src/bitcoinrpc.cpp ede2e19dd0ce3d03f54689cbeda30b4b36152f7e532b3d34f0f8c55bb292f7d25c149b88162d96a8208997237a32566d0e555aa7105bfed8175983d80ad892e6
+++ b/bitcoin/src/bitcoinrpc.cpp 84193f267fe20cdd9bc3a525ca206d4c00ab8b732ab386e4582e77e96e2574b08da2916e927839c8c1247867e42c9b9124f48546626f675f1d8cea705ac87b3a
@@ -2139,12 +2139,12 @@
vnThreadsRunning[4]--;
PrintException(NULL, "ThreadRPCServer()");
}
- printf("ThreadRPCServer exiting\n");
+ printf(SINF SNET "rpc server thread exiting\n");
}
void ThreadRPCServer2(void* parg)
{
- printf("ThreadRPCServer started\n");
+ printf(SINF SNET "rpc server thread started\n");
strRPCUserColonPass = mapArgs["-rpcuser"] + ":" + mapArgs["-rpcpassword"];
if (strRPCUserColonPass == ":")
@@ -2207,7 +2207,7 @@
if (!api_caller.timed_join(boost::posix_time::seconds(GetArg("-rpctimeout", 30))))
{ // Timed out:
acceptor.cancel();
- printf("ThreadRPCServer ReadHTTP timeout\n");
+ printf(SINF SNET "rpc server thread timeout\n");
continue;
}
@@ -2219,7 +2219,7 @@
}
if (!HTTPAuthorized(mapHeaders))
{
- printf("ThreadRPCServer incorrect password attempt from %s\n",peer.address().to_string().c_str());
+ printf(SWAR SNET "incorrect rpc password attempt from %s\n",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.*/
@@ -2250,7 +2250,7 @@
throw JSONRPCError(-32600, "Method must be a string");
string strMethod = valMethod.get_str();
if (strMethod != "getwork" && strMethod != "getmemorypool")
- printf("ThreadRPCServer method=%s\n", strMethod.c_str());
+ printf(SINF SNET "rpc server received request using method %s\n", strMethod.c_str());
// Parse params
Value valParams = find_value(request, "params");
diff -uNr a/bitcoin/src/db.cpp b/bitcoin/src/db.cpp
--- a/bitcoin/src/db.cpp 565faf3ef371f5e2178ae30c45b08b93415eeb92263486e68f2ac2e8f4c7900056e628804bf5c0707a90be946e0aeaebfcd0a391aab40de2e5d56e6bcbdccb1e
+++ b/bitcoin/src/db.cpp 93e1c42f397a6996dc73fb5ca1a13f1ec36f2e129782c97e0e45ff3058c943660a04d660dfc94db01a6240c6c6b622a32e4ca57fa78ec580fc1065dce4dc2579
@@ -40,7 +40,7 @@
}
catch (const DbException& e)
{
- printf("EnvShutdown exception: %s (%d)\n", e.what(), e.get_errno());
+ printf(SWAR SPRC "shutdown exception: %s (%d)\n", e.what(), e.get_errno());
}
DbEnv(0).remove(GetDataDir().c_str(), 0);
}
@@ -81,7 +81,8 @@
string strLogDir = strDataDir + "/database";
filesystem::create_directory(strLogDir.c_str());
string strErrorFile = strDataDir + "/db.log";
- printf("dbenv.open strLogDir=%s strErrorFile=%s\n", strLogDir.c_str(), strErrorFile.c_str());
+ printf(SINF SBLK "using database directory: %s\n", strLogDir.c_str());
+ printf(SINF SBLK "using database log: %s\n", strErrorFile.c_str());
dbenv.set_lg_dir(strLogDir.c_str());
dbenv.set_lg_max(1000000);
@@ -196,7 +197,7 @@
mapFileUseCount.erase(strFile);
bool fSuccess = true;
- printf("Rewriting %s...\n", strFile.c_str());
+ printf(SWAR SBLK "rewriting database file %s\n", strFile.c_str());
string strFileRes = strFile + ".rewrite";
{ // surround usage of db with extra {}
CDB db(strFile.c_str(), "r");
@@ -210,7 +211,7 @@
0);
if (ret > 0)
{
- printf("Cannot create database file %s\n", strFileRes.c_str());
+ printf(SERR SBLK "can't create database file %s\n", strFileRes.c_str());
fSuccess = false;
}
@@ -266,7 +267,7 @@
fSuccess = false;
}
if (!fSuccess)
- printf("Rewriting of %s FAILED!\n", strFileRes.c_str());
+ printf(SERR SBLK "rewriting of database file %s\n", strFileRes.c_str());
return fSuccess;
}
}
@@ -280,7 +281,7 @@
{
// Flush log data to the actual data file
// on all files that are not in use
- printf("DBFlush(%s)%s\n", fShutdown ? "true" : "false", fDbEnvInit ? "" : " db not started");
+ printf(SINF SBLK "flushing log data. %s\n", fShutdown ? "shutting down" : "");
if (!fDbEnvInit)
return;
CRITICAL_BLOCK(cs_db)
@@ -290,13 +291,13 @@
{
string strFile = (*mi).first;
int nRefCount = (*mi).second;
- printf("%s refcount=%d\n", strFile.c_str(), nRefCount);
+ printf(SINF SBLK "database file %s has refcount %d\n", strFile.c_str(), nRefCount);
if (nRefCount == 0)
{
// Move log data to the dat file
CloseDb(strFile);
dbenv.txn_checkpoint(0, 0, 0);
- printf("%s flush\n", strFile.c_str());
+ printf(SINF SBLK "flushing database file %s\n", strFile.c_str());
dbenv.lsn_reset(strFile.c_str(), 0);
mapFileUseCount.erase(mi++);
}
@@ -540,7 +541,7 @@
pindexGenesisBlock = pindexNew;
if (!pindexNew->CheckIndex())
- return error("LoadBlockIndex() : CheckIndex failed at %d", pindexNew->nHeight);
+ return error(SBLK "block index check failed at height %d", pindexNew->nHeight);
}
else
{
@@ -569,14 +570,14 @@
{
if (pindexGenesisBlock == NULL)
return true;
- return error("CTxDB::LoadBlockIndex() : hashBestChain not loaded");
+ return error(SBLK "chain tip loading failed");
}
if (!mapBlockIndex.count(hashBestChain))
- return error("CTxDB::LoadBlockIndex() : hashBestChain not found in the block index");
+ return error(SBLK "chain tip %s not found in the block index", hashBestChain.ToString().c_str());
pindexBest = mapBlockIndex[hashBestChain];
nBestHeight = pindexBest->nHeight;
bnBestChainWork = pindexBest->bnChainWork;
- printf("LoadBlockIndex(): hashBestChain=%s height=%d\n", hashBestChain.ToString().substr(0,20).c_str(), nBestHeight);
+ printf(SINF SBLK "chain tip %s at height %d\n", hashBestChain.ToString().c_str(), nBestHeight);
// Load bnBestInvalidWork, OK if it doesn't exist
ReadBestInvalidWork(bnBestInvalidWork);
@@ -589,20 +590,22 @@
break;
CBlock block;
if (!block.ReadFromDisk(pindex))
- return error("LoadBlockIndex() : block.ReadFromDisk failed");
+ return error(SBLK "block loading from disk failed");
if (!block.CheckBlock())
{
- printf("LoadBlockIndex() : *** found bad block at %d, hash=%s\n", pindex->nHeight, pindex->GetBlockHash().ToString().c_str());
+ printf(SWAR SBLK "found bad block %s at height %d\n",
+ pindex->GetBlockHash().ToString().c_str(), pindex->nHeight);
pindexFork = pindex->pprev;
}
}
if (pindexFork)
{
// Reorg back to the fork
- printf("LoadBlockIndex() : *** moving best chain pointer back to block %d\n", pindexFork->nHeight);
+ printf(SINF SBLK "setting best chain pointer to block %s at height %d\n",
+ pindexFork->GetBlockHash().ToString().c_str(), pindexFork->nHeight);
CBlock block;
if (!block.ReadFromDisk(pindexFork))
- return error("LoadBlockIndex() : block.ReadFromDisk failed");
+ return error(SBLK "block loading from disk failed");
CTxDB txdb;
block.SetBestChain(txdb, pindexFork);
}
@@ -660,7 +663,7 @@
}
pcursor->close();
- printf("Loaded %d addresses\n", mapAddresses.size());
+ printf(SINF SADR "loaded %d addresses\n", mapAddresses.size());
}
return true;
@@ -814,7 +817,7 @@
wtx.pwallet = pwallet;
if (wtx.GetHash() != hash)
- printf("Error in wallet.dat, hash mismatch\n");
+ printf(SERR SWAL "hash mismatch in wallet.dat\n");
// Undo serialize changes in 31600
if (31404 <= wtx.fTimeReceivedIsTxTime && wtx.fTimeReceivedIsTxTime <= 31703)
@@ -824,12 +827,12 @@
char fTmp;
char fUnused;
ssValue >> fTmp >> fUnused >> wtx.strFromAccount;
- printf("LoadWallet() upgrading tx ver=%d %d '%s' %s\n", wtx.fTimeReceivedIsTxTime, fTmp, wtx.strFromAccount.c_str(), hash.ToString().c_str());
+ printf(SINF SWAL "upgrading tx version to %d\n", wtx.fTimeReceivedIsTxTime);
wtx.fTimeReceivedIsTxTime = fTmp;
}
else
{
- printf("LoadWallet() repairing tx ver=%d %s\n", wtx.fTimeReceivedIsTxTime, hash.ToString().c_str());
+ printf(SWAR SWAL "repairing tx version %d\n", wtx.fTimeReceivedIsTxTime);
wtx.fTimeReceivedIsTxTime = 0;
}
vWalletUpgrade.push_back(hash);
@@ -943,13 +946,15 @@
BOOST_FOREACH(uint256 hash, vWalletUpgrade)
WriteTx(hash, pwallet->mapWallet[hash]);
- printf("nFileVersion = %d\n", nFileVersion);
- printf("fGenerateBitcoins = %d\n", fGenerateBitcoins);
- printf("nTransactionFee = %"PRI64d"\n", nTransactionFee);
- printf("fMinimizeToTray = %d\n", fMinimizeToTray);
- printf("fMinimizeOnClose = %d\n", fMinimizeOnClose);
- printf("fUseProxy = %d\n", fUseProxy);
- printf("addrProxy = %s\n", addrProxy.ToString().c_str());
+ printf(SINF SWAL "file version is %d\n", nFileVersion);
+
+ if (fGenerateBitcoins)
+ printf(SINF SMIN "miner was activated\n");
+
+ printf(SINF SMEM "transaction fee is %"PRI64d"\n", nTransactionFee);
+
+ if (fUseProxy)
+ printf(SINF SNET "connecting through proxy on address %s\n", addrProxy.ToString().c_str());
// Rewrite encrypted wallets of versions 0.4.0 and 0.5.0rc:
if (fIsEncrypted && (nFileVersion == 40000 || nFileVersion == 50000))
@@ -1008,8 +1013,7 @@
map<string, int>::iterator mi = mapFileUseCount.find(strFile);
if (mi != mapFileUseCount.end())
{
- printf("%s ", DateTimeStrFormat("%x %H:%M:%S", GetTime()).c_str());
- printf("Flushing wallet.dat\n");
+ printf(SWAR SWAL "flushing wallet.dat\n");
nLastFlushed = nWalletDBUpdated;
int64 nStart = GetTimeMillis();
@@ -1019,7 +1023,7 @@
dbenv.lsn_reset(strFile.c_str(), 0);
mapFileUseCount.erase(mi++);
- printf("Flushed wallet.dat %"PRI64d"ms\n", GetTimeMillis() - nStart);
+ printf(SWAR SWAL "flushed wallet.dat in %"PRI64d"ms\n", GetTimeMillis() - nStart);
}
}
}
@@ -1053,7 +1057,7 @@
#else
filesystem::copy_file(pathSrc, pathDest);
#endif
- printf("copied wallet.dat to %s\n", pathDest.string().c_str());
+ printf(SINF SWAL "copied wallet.dat to %s\n", pathDest.string().c_str());
return true;
}
diff -uNr a/bitcoin/src/init.cpp b/bitcoin/src/init.cpp
--- a/bitcoin/src/init.cpp 3ad5a434f08b5029a39bb0e57216a37ae0047caf1f05cb2984796e9c80fc4ceb9fb9ffe3ca067c9bffb12ffe465e3d92408a79a5e940c66253a358f393b6c29f
+++ b/bitcoin/src/init.cpp 84add359f786307d38b7fccae320bc384fdfb92f70cf2bb232d7ab48b6a9739d3babe091acffa7e2c09c7e5b145c63aa08c3ca787a0b6ce7ae44a2b2c62426fd
@@ -50,7 +50,7 @@
delete pwalletMain;
CreateThread(ExitTimeout, NULL);
Sleep(50);
- printf("Bitcoin exiting\n\n");
+ printf(SINF SPRC "bitcoind exiting\n");
fExit = true;
exit(0);
}
@@ -262,9 +262,8 @@
fprintf(stderr, "Error: setsid() returned %d errno %d\n", sid, errno);
}
- printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
- printf("Bitcoin version %s\n", FormatFullVersion().c_str());
- printf("Default data directory %s\n", GetDefaultDataDir().c_str());
+ printf(SINF SPRC "bitcoind %s starting\n", FormatFullVersion().c_str());
+ printf(SINF SPRC "using data directory: %s\n", GetDataDir().c_str());
if (GetBoolArg("-loadblockindextest"))
{
@@ -296,21 +295,21 @@
int64 nStart;
InitMessage(_("Loading addresses..."));
- printf("Loading addresses...\n");
+ printf(SINF SADR "loading addresses\n");
nStart = GetTimeMillis();
if (!LoadAddresses())
strErrors += _("Error loading addr.dat \n");
- printf(" addresses %15"PRI64d"ms\n", GetTimeMillis() - nStart);
+ printf(SINF SADR "loaded addresses in %"PRI64d"ms\n", GetTimeMillis() - nStart);
InitMessage(_("Loading block index..."));
- printf("Loading block index...\n");
+ printf(SINF SBLK "loading block index\n");
nStart = GetTimeMillis();
if (!LoadBlockIndex())
strErrors += _("Error loading blkindex.dat \n");
- printf(" block index %15"PRI64d"ms\n", GetTimeMillis() - nStart);
+ printf(SINF SBLK "loaded block index in %"PRI64d"ms\n", GetTimeMillis() - nStart);
InitMessage(_("Loading wallet..."));
- printf("Loading wallet...\n");
+ printf(SINF SWAL "loading wallet\n");
nStart = GetTimeMillis();
bool fFirstRun;
pwalletMain = new CWallet("wallet.dat");
@@ -330,7 +329,7 @@
else
strErrors += _("Error loading wallet.dat \n");
}
- printf(" wallet %15"PRI64d"ms\n", GetTimeMillis() - nStart);
+ printf(SINF SWAL "loaded wallet in %"PRI64d"ms\n", GetTimeMillis() - nStart);
RegisterWallet(pwalletMain);
@@ -347,21 +346,21 @@
if (pindexBest != pindexRescan)
{
InitMessage(_("Rescanning..."));
- printf("Rescanning last %i blocks (from block %i)...\n", pindexBest->nHeight - pindexRescan->nHeight, pindexRescan->nHeight);
+ printf(SINF SBLK "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);
+ printf(SINF SBLK "rescanned in %"PRI64d"ms\n", GetTimeMillis() - nStart);
}
InitMessage(_("Done loading"));
- printf("Done loading\n");
+ printf(SINF SPRC "done loading\n");
//// debug print
- printf("mapBlockIndex.size() = %d\n", mapBlockIndex.size());
- printf("nBestHeight = %d\n", nBestHeight);
- printf("setKeyPool.size() = %d\n", pwalletMain->setKeyPool.size());
- printf("mapWallet.size() = %d\n", pwalletMain->mapWallet.size());
- printf("mapAddressBook.size() = %d\n", pwalletMain->mapAddressBook.size());
+ printf(SINF SBLK "block index size: %d\n", mapBlockIndex.size());
+ printf(SINF SBLK "best height: %d\n", nBestHeight);
+ printf(SINF SWAL "keypool size: %d\n", pwalletMain->setKeyPool.size());
+ printf(SINF SWAL "wallet size: %d\n", pwalletMain->mapWallet.size());
+ printf(SINF SADR "address index size: %d\n", pwalletMain->mapAddressBook.size());
if (!strErrors.empty())
{
@@ -406,12 +405,11 @@
block.ReadFromDisk(pindex);
block.BuildMerkleTree();
block.print();
- printf("\n");
nFound++;
}
}
if (nFound == 0)
- printf("No blocks matching %s were found\n", strMatch.c_str());
+ printf(SERR SBLK "no blocks matching %s were found\n", strMatch.c_str());
return false;
}
diff -uNr a/bitcoin/src/main.cpp b/bitcoin/src/main.cpp
--- a/bitcoin/src/main.cpp 02ccc72e42939509fc180861db7ffec50563a84869f35671fcf720090f9782674edcc89c4174175691566fac7277f1ebe0f50253d1e4a995eb960f5b43cce2a3
+++ b/bitcoin/src/main.cpp b4775d56fd901d7af16136590be4645f57631004c4e0ec35332374eedc78d8574d6a2162d7bba121843f710111209336ecd6553af4b576bad81b3639d2634ad5
@@ -213,7 +213,7 @@
{
vMerkleBranch.clear();
nIndex = -1;
- printf("ERROR: SetMerkleBranch() : couldn't find tx in block\n");
+ printf(SERR SBLK "couldn't set merkle branch, tx not included in a block\n");
return 0;
}
@@ -242,24 +242,29 @@
{
// Basic checks that don't depend on any context
if (vin.empty())
- return DoS(10, error("CTransaction::CheckTransaction() : vin empty"));
+ return DoS(10, error(SMEM "tx %s validation failed, no inputs",
+ GetHash().ToString().c_str()));
if (vout.empty())
- return DoS(10, error("CTransaction::CheckTransaction() : vout empty"));
+ return DoS(10, error(SMEM "tx %s validation failed, no ouputs",
+ GetHash().ToString().c_str()));
// Size limits
if (::GetSerializeSize(*this, SER_NETWORK) > MAX_BLOCK_SIZE)
- return DoS(100, error("CTransaction::CheckTransaction() : size limits failed"));
-
+ return DoS(100, error(SMEM "tx %s validation failed, size limits failed",
+ GetHash().ToString().c_str()));
// Check for negative or overflow output values
int64 nValueOut = 0;
BOOST_FOREACH(const CTxOut& txout, vout)
{
if (txout.nValue < 0)
- return DoS(100, error("CTransaction::CheckTransaction() : txout.nValue negative"));
+ return DoS(100, error(SMEM "tx %s validation failed, output amount is negative",
+ GetHash().ToString().c_str()));
if (txout.nValue > MAX_MONEY)
- return DoS(100, error("CTransaction::CheckTransaction() : txout.nValue too high"));
+ return DoS(100, error(SMEM "tx %s validation failed, output amount out of range",
+ GetHash().ToString().c_str()));
nValueOut += txout.nValue;
if (!MoneyRange(nValueOut))
- return DoS(100, error("CTransaction::CheckTransaction() : txout total out of range"));
+ return DoS(100, error(SMEM "tx %s validation failed, total output amount out of range",
+ GetHash().ToString().c_str()));
}
// Check for duplicate inputs
@@ -267,20 +272,23 @@
BOOST_FOREACH(const CTxIn& txin, vin)
{
if (vInOutPoints.count(txin.prevout))
- return false;
+ return error(SMEM "tx %s validation failed, duplicate input found",
+ GetHash().ToString().c_str());
vInOutPoints.insert(txin.prevout);
}
if (IsCoinBase())
{
if (vin[0].scriptSig.size() < 2 || vin[0].scriptSig.size() > 100)
- return DoS(100, error("CTransaction::CheckTransaction() : coinbase script size"));
+ return DoS(100, error(SMEM "tx %s validation failed, coinbase script size out of range",
+ GetHash().ToString().c_str()));
}
else
{
BOOST_FOREACH(const CTxIn& txin, vin)
if (txin.prevout.IsNull())
- return DoS(10, error("CTransaction::CheckTransaction() : prevout is null"));
+ return DoS(10, error(SMEM "tx %s validation failed, input specifies no previous output",
+ GetHash().ToString().c_str()));
}
return true;
@@ -292,15 +300,17 @@
*pfMissingInputs = false;
if (!CheckTransaction())
- return error("AcceptToMemoryPool() : CheckTransaction failed");
+ return error(SMEM "tx %s rejected", GetHash().ToString().c_str());
// Coinbase is only valid in a block, not as a loose transaction
if (IsCoinBase())
- return DoS(100, error("AcceptToMemoryPool() : coinbase as individual tx"));
+ return DoS(100, error(SMEM "tx %s rejected, coinbase individual tx",
+ GetHash().ToString().c_str()));
// To help v0.1.5 clients who would see it as a negative number
if ((int64)nLockTime > INT_MAX)
- return error("AcceptToMemoryPool() : not accepting nLockTime beyond 2038 yet");
+ return error(SMEM "tx %s rejected, locktime out of range",
+ GetHash().ToString().c_str());
// Safety limits
unsigned int nSize = ::GetSerializeSize(*this, SER_NETWORK);
@@ -309,11 +319,13 @@
// 34 bytes because a TxOut is:
// 20-byte address + 8 byte bitcoin amount + 5 bytes of ops + 1 byte script length
if (GetSigOpCount() > nSize / 34 || nSize < 100)
- return error("AcceptToMemoryPool() : transaction with out-of-bounds SigOpCount");
+ return error(SMEM "tx %s rejected, sigop count out of range",
+ GetHash().ToString().c_str());
// Rather not work on nonstandard transactions
if (!IsStandard())
- return error("AcceptToMemoryPool() : nonstandard transaction type");
+ return error(SMEM "tx %s rejected, non-standard tx",
+ GetHash().ToString().c_str());
// Do we already have it?
uint256 hash = GetHash();
@@ -361,13 +373,13 @@
if (!ConnectInputs(txdb, mapUnused, CDiskTxPos(1,1,1), pindexBest, nFees, false, false, 0, fInvalid))
{
if (fInvalid)
- return error("AcceptToMemoryPool() : FetchInputs found invalid tx %s", hash.ToString().substr(0,10).c_str());
- return error("AcceptToMemoryPool() : ConnectInputs failed %s", hash.ToString().substr(0,10).c_str());
+ return error(SMEM "tx %s rejected, invalid input", hash.ToString().c_str());
+ return error(SMEM "tx %s rejected, input not found", hash.ToString().c_str());
}
// Don't accept it if it can't get into a block
if (nFees < GetMinFee(1000, true, true))
- return error("AcceptToMemoryPool() : not enough fees");
+ return error(SMEM "tx %s rejected, not enough fees", hash.ToString().c_str());
// Continuously rate-limit free transactions
// This mitigates 'penny-flooding' -- sending thousands of free transactions just to
@@ -387,9 +399,10 @@
// -limitfreerelay unit is thousand-bytes-per-minute
// At default rate it would take over a month to fill 1GB
if (dFreeCount > GetArg("-limitfreerelay", 15)*10*1000 && !IsFromMe(*this))
- return error("AcceptToMemoryPool() : free transaction rejected by rate limiter");
+ return error(SMEM "tx %s rejected, free tx",
+ hash.ToString().c_str());
if (fDebug)
- printf("Rate limit dFreeCount: %g => %g\n", dFreeCount, dFreeCount+nSize);
+ printf(SINF SMEM "updated free tx rate limit from %g to %g\n", dFreeCount, dFreeCount+nSize);
dFreeCount += nSize;
}
}
@@ -400,7 +413,8 @@
{
if (ptxOld)
{
- printf("AcceptToMemoryPool() : replacing tx %s with new version\n", ptxOld->GetHash().ToString().c_str());
+ printf(SWAR SMEM "replacing tx %s with new tx %s\n", ptxOld->GetHash().ToString().c_str(),
+ hash.ToString().c_str());
ptxOld->RemoveFromMemoryPool();
}
AddToMemoryPoolUnchecked();
@@ -411,7 +425,7 @@
if (ptxOld)
EraseFromWallets(ptxOld->GetHash());
- printf("AcceptToMemoryPool(): accepted %s\n", hash.ToString().substr(0,10).c_str());
+ printf(SINF SMEM "accepted tx %s\n", hash.ToString().c_str());
return true;
}
@@ -576,7 +590,7 @@
if (!ReadFromDisk(pindex->nFile, pindex->nBlockPos, fReadTransactions))
return false;
if (GetHash() != pindex->GetBlockHash())
- return error("CBlock::ReadFromDisk() : GetHash() doesn't match index");
+ return error(SBLK "block %s doesn't match index", GetHash().ToString().c_str());
return true;
}
@@ -636,7 +650,7 @@
// Limit adjustment step
int64 nActualTimespan = pindexLast->GetBlockTime() - pindexFirst->GetBlockTime();
- printf(" nActualTimespan = %"PRI64d" before bounds\n", nActualTimespan);
+ printf(SINF SBLK "actual timestamp before bounds is %"PRI64d"\n", nActualTimespan);
if (nActualTimespan < nTargetTimespan/4)
nActualTimespan = nTargetTimespan/4;
if (nActualTimespan > nTargetTimespan*4)
@@ -652,10 +666,11 @@
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());
+ printf(SINF SBLK "retargetting\n");
+ printf(SINF SBLK "target timestamp is %"PRI64d" and actual timespan is %"PRI64d"\n", nTargetTimespan, nActualTimespan);
+ printf(SINF SBLK "before: %08x %s\n", pindexLast->nBits,
+ CBigNum().SetCompact(pindexLast->nBits).getuint256().ToString().c_str());
+ printf(SINF SBLK "after: %08x %s\n", bnNew.GetCompact(), bnNew.getuint256().ToString().c_str());
return bnNew.GetCompact();
}
@@ -667,11 +682,11 @@
// Check range
if (bnTarget <= 0 || bnTarget > bnProofOfWorkLimit)
- return error("CheckProofOfWork() : nBits below minimum work");
+ return error(SBLK "pow %s work below minimum (%u)", hash.ToString().c_str(), nBits);
// Check proof of work matches claimed amount
if (hash > bnTarget.getuint256())
- return error("CheckProofOfWork() : hash doesn't match nBits");
+ return error(SBLK "pow %s hash doesn't match work (%u)", hash.ToString().c_str(), nBits);
return true;
}
@@ -705,10 +720,13 @@
CTxDB().WriteBestInvalidWork(bnBestInvalidWork);
MainFrameRepaint();
}
- printf("InvalidChainFound: invalid block=%s height=%d work=%s\n", pindexNew->GetBlockHash().ToString().substr(0,20).c_str(), pindexNew->nHeight, pindexNew->bnChainWork.ToString().c_str());
- printf("InvalidChainFound: current best=%s height=%d work=%s\n", hashBestChain.ToString().substr(0,20).c_str(), nBestHeight, bnBestChainWork.ToString().c_str());
+ printf(SERR SBLK "invalid chain tip %s at height %d with work %s\n",
+ pindexNew->GetBlockHash().ToString().c_str(), pindexNew->nHeight,
+ pindexNew->bnChainWork.ToString().c_str());
+ printf(SINF SBLK "best chain tip %s at height %d with work %s\n",
+ hashBestChain.ToString().c_str(), nBestHeight, bnBestChainWork.ToString().c_str());
if (pindexBest && bnBestInvalidWork > bnBestChainWork + pindexBest->GetBlockWork() * 6)
- printf("InvalidChainFound: WARNING: Displayed transactions may not be correct! You may need to upgrade, or other nodes may need to upgrade.\n");
+ printf(SWAR SBLK "displayed transactions may not be correct, there's chain discrepancy between this and other nodes\n");
}
@@ -733,17 +751,19 @@
// Get prev txindex from disk
CTxIndex txindex;
if (!txdb.ReadTxIndex(prevout.hash, txindex))
- return error("DisconnectInputs() : ReadTxIndex failed");
+ return error(SMEM "input referenced non-existing output %d from tx %s",
+ prevout.n, prevout.hash.ToString().c_str());
if (prevout.n >= txindex.vSpent.size())
- return error("DisconnectInputs() : prevout.n out of range");
+ return error(SMEM "input referenced out of range output %d from tx %s ",
+ prevout.n, prevout.hash.ToString().c_str());
// Mark outpoint as not spent
txindex.vSpent[prevout.n].SetNull();
// Write back
if (!txdb.UpdateTxIndex(prevout.hash, txindex))
- return error("DisconnectInputs() : UpdateTxIndex failed");
+ return error(SMEM "tx index can't be updated");
}
}
@@ -792,7 +812,8 @@
fFound = txdb.ReadTxIndex(prevout.hash, txindex);
}
if (!fFound && (fBlock || fMiner))
- return fMiner ? false : error("ConnectInputs() : %s prev tx %s index entry not found", GetHash().ToString().substr(0,10).c_str(), prevout.hash.ToString().substr(0,10).c_str());
+ return fMiner ? false : error(SMEM "tx %s not found in index",
+ prevout.hash.ToString().c_str());
// Read txPrev
CTransaction txPrev;
@@ -802,7 +823,8 @@
CRITICAL_BLOCK(cs_mapTransactions)
{
if (!mapTransactions.count(prevout.hash))
- return error("ConnectInputs() : %s mapTransactions prev not found %s", GetHash().ToString().substr(0,10).c_str(), prevout.hash.ToString().substr(0,10).c_str());
+ return error(SMEM "tx %s not found in memory pool",
+ prevout.hash.ToString().c_str());
txPrev = mapTransactions[prevout.hash];
}
if (!fFound)
@@ -812,7 +834,8 @@
{
// Get prev tx from disk
if (!txPrev.ReadFromDisk(txindex.pos))
- return error("ConnectInputs() : %s ReadFromDisk prev tx %s failed", GetHash().ToString().substr(0,10).c_str(), prevout.hash.ToString().substr(0,10).c_str());
+ return error(SMEM "tx %s not found in disk",
+ prevout.hash.ToString().c_str());
}
if (prevout.n >= txPrev.vout.size() || prevout.n >= txindex.vSpent.size())
@@ -820,14 +843,16 @@
// Revisit this if/when transaction replacement is implemented and allows
// adding inputs:
fInvalid = true;
- return DoS(100, error("ConnectInputs() : %s prevout.n out of range %d %d %d prev tx %s\n%s", GetHash().ToString().substr(0,10).c_str(), prevout.n, txPrev.vout.size(), txindex.vSpent.size(), prevout.hash.ToString().substr(0,10).c_str(), txPrev.ToString().c_str()));
+ return DoS(100, error(SMEM "output %d from tx %s is out of range",
+ prevout.n, prevout.hash.ToString().c_str()));
}
// If prev is coinbase, check that it's matured
if (txPrev.IsCoinBase())
for (CBlockIndex* pindex = pindexBlock; pindex && pindexBlock->nHeight - pindex->nHeight < COINBASE_MATURITY; pindex = pindex->pprev)
if (pindex->nBlockPos == txindex.pos.nBlockPos && pindex->nFile == txindex.pos.nFile)
- return error("ConnectInputs() : tried to spend coinbase at depth %d", pindexBlock->nHeight - pindex->nHeight);
+ return error(SMEM "tx %s tried to spend coinbase at depth %d",
+ GetHash().ToString().c_str(), pindexBlock->nHeight - pindex->nHeight);
// Skip ECDSA signature verification when connecting blocks (fBlock=true)
// before the last blockchain checkpoint. This is safe because block merkle hashes are
@@ -835,18 +860,21 @@
if (fVerifyAll || (!(fBlock && (nBestHeight < Checkpoints::GetTotalBlocksEstimate()))))
// Verify signature
if (!VerifySignature(txPrev, *this, i))
- return DoS(100,error("ConnectInputs() : %s VerifySignature failed", GetHash().ToString().substr(0,10).c_str()));
+ return DoS(100,error(SMEM "tx %s signature verification failed",
+ GetHash().ToString().c_str()));
// Check for conflicts (double-spend)
// This doesn't trigger the DoS code on purpose; if it did, it would make it easier
// for an attacker to attempt to split the network.
if (!txindex.vSpent[prevout.n].IsNull())
- return fMiner ? false : error("ConnectInputs() : %s prev tx already used at %s", GetHash().ToString().substr(0,10).c_str(), txindex.vSpent[prevout.n].ToString().c_str());
+ return fMiner ? false : error(SMEM "output %d from tx %s already spent",
+ prevout.n, prevout.hash.ToString().c_str());
// Check for negative or overflow input values
nValueIn += txPrev.vout[prevout.n].nValue;
if (!MoneyRange(txPrev.vout[prevout.n].nValue) || !MoneyRange(nValueIn))
- return DoS(100, error("ConnectInputs() : txin values out of range"));
+ return DoS(100, error(SMEM "output %d from tx %s contains out of range amount",
+ prevout.n, prevout.hash.ToString().c_str()));
// Mark outpoints as spent
txindex.vSpent[prevout.n] = posThisTx;
@@ -858,18 +886,20 @@
}
}
- if (nValueIn < GetValueOut())
- return DoS(100, error("ConnectInputs() : %s value in < value out", GetHash().ToString().substr(0,10).c_str()));
+ int64 nValueOut = GetValueOut();
+ if (nValueIn < nValueOut)
+ return DoS(100, error(SMEM "tx %s output amount is greater than input amount",
+ GetHash().ToString().c_str()));
// Tally transaction fees
- int64 nTxFee = nValueIn - GetValueOut();
+ int64 nTxFee = nValueIn - nValueOut;
if (nTxFee < 0)
- return DoS(100, error("ConnectInputs() : %s nTxFee < 0", GetHash().ToString().substr(0,10).c_str()));
+ return DoS(100, error(SMEM "tx %s fee is negative", GetHash().ToString().c_str()));
if (nTxFee < nMinFee)
return false;
nFees += nTxFee;
if (!MoneyRange(nFees))
- return DoS(100, error("ConnectInputs() : nFees out of range"));
+ return DoS(100, error(SMEM "tx %s fee is out of range", GetHash().ToString().c_str()));
}
if (fBlock)
@@ -909,7 +939,8 @@
// Verify signature
if (!VerifySignature(txPrev, *this, i))
- return error("ConnectInputs() : VerifySignature failed");
+ return error(SMEM "tx %s signature verification against tx %s failed",
+ GetHash().ToString().c_str(), txPrev.GetHash().ToString().c_str());
///// this is redundant with the mapNextTx stuff, not sure which I want to get rid of
///// this has to go away now that posNext is gone
@@ -923,7 +954,8 @@
nValueIn += txPrev.vout[prevout.n].nValue;
if (!MoneyRange(txPrev.vout[prevout.n].nValue) || !MoneyRange(nValueIn))
- return error("ClientConnectInputs() : txin values out of range");
+ return error(SMEM "tx %s input amounts are out of range",
+ GetHash().ToString().c_str());
}
if (GetValueOut() > nValueIn)
return false;
@@ -949,7 +981,7 @@
CDiskBlockIndex blockindexPrev(pindex->pprev);
blockindexPrev.hashNext = 0;
if (!txdb.WriteBlockIndex(blockindexPrev))
- return error("DisconnectBlock() : WriteBlockIndex failed");
+ return error(SBLK "writing to block index failed while disconnecting block");
}
return true;
@@ -998,7 +1030,7 @@
for (map<uint256, CTxIndex>::iterator mi = mapQueuedChanges.begin(); mi != mapQueuedChanges.end(); ++mi)
{
if (!txdb.UpdateTxIndex((*mi).first, (*mi).second))
- return error("ConnectBlock() : UpdateTxIndex failed");
+ return error(SMEM "tx index update failed");
}
if (vtx[0].GetValueOut() > GetBlockValue(pindex->nHeight, nFees))
@@ -1011,7 +1043,7 @@
CDiskBlockIndex blockindexPrev(pindex->pprev);
blockindexPrev.hashNext = pindex->GetBlockHash();
if (!txdb.WriteBlockIndex(blockindexPrev))
- return error("ConnectBlock() : WriteBlockIndex failed");
+ return error(SBLK "writing to block index failed while connecting block");
}
// Watch for transactions paying to me
@@ -1023,7 +1055,7 @@
bool static Reorganize(CTxDB& txdb, CBlockIndex* pindexNew)
{
- printf("REORGANIZE\n");
+ printf(SINF SBLK "reorganizing block index\n");
// Find the fork
CBlockIndex* pfork = pindexBest;
@@ -1032,11 +1064,11 @@
{
while (plonger->nHeight > pfork->nHeight)
if (!(plonger = plonger->pprev))
- return error("Reorganize() : plonger->pprev is null");
+ return error(SBLK "invalid pointer to previous block from longest chain tip");
if (pfork == plonger)
break;
if (!(pfork = pfork->pprev))
- return error("Reorganize() : pfork->pprev is null");
+ return error(SBLK "invalid pointer to previous block from new longest chain tip");
}
// List of what to disconnect
@@ -1056,9 +1088,9 @@
{
CBlock block;
if (!block.ReadFromDisk(pindex))
- return error("Reorganize() : ReadFromDisk for disconnect failed");
+ return error(SBLK "block loading from disk failed while trying to disconnect block");
if (!block.DisconnectBlock(txdb, pindex))
- return error("Reorganize() : DisconnectBlock failed");
+ return error(SBLK "block index reorganization failed while trying to disconnect block");
// Queue memory transactions to resurrect
BOOST_FOREACH(const CTransaction& tx, block.vtx)
@@ -1073,12 +1105,12 @@
CBlockIndex* pindex = vConnect[i];
CBlock block;
if (!block.ReadFromDisk(pindex))
- return error("Reorganize() : ReadFromDisk for connect failed");
+ return error(SBLK "block loading from disk failed while trying to connect block");
if (!block.ConnectBlock(txdb, pindex))
{
// Invalid block
txdb.TxnAbort();
- return error("Reorganize() : ConnectBlock failed");
+ return error(SBLK "block index reorganization failed while trying to connect block");
}
// Queue memory transactions to delete
@@ -1086,11 +1118,11 @@
vDelete.push_back(tx);
}
if (!txdb.WriteHashBestChain(pindexNew->GetBlockHash()))
- return error("Reorganize() : WriteHashBestChain failed");
+ return error(SBLK "block writing to index failed while trying to save best chain");
// Make sure it's successfully written to disk before changing memory structure
if (!txdb.TxnCommit())
- return error("Reorganize() : TxnCommit failed");
+ return error(SMEM "tx index commitment failed while reorganizing block index");
// Disconnect shorter branch
BOOST_FOREACH(CBlockIndex* pindex, vDisconnect)
@@ -1123,7 +1155,7 @@
{
txdb.WriteHashBestChain(hash);
if (!txdb.TxnCommit())
- return error("SetBestChain() : TxnCommit failed");
+ return error(SMEM "tx index commitment failed while setting best chain");
pindexGenesisBlock = pindexNew;
}
else if (hashPrevBlock == hashBestChain)
@@ -1133,10 +1165,10 @@
{
txdb.TxnAbort();
InvalidChainFound(pindexNew);
- return error("SetBestChain() : ConnectBlock failed");
+ return error(SBLK "block connecting failed while setting best chain");
}
if (!txdb.TxnCommit())
- return error("SetBestChain() : TxnCommit failed");
+ return error(SMEM "tx index commitment failed while setting best chain");
// Add to current best branch
pindexNew->pprev->pnext = pindexNew;
@@ -1152,7 +1184,7 @@
{
txdb.TxnAbort();
InvalidChainFound(pindexNew);
- return error("SetBestChain() : Reorganize failed");
+ return error(SBLK "block reorganization failed while setting best chain");
}
}
@@ -1170,7 +1202,7 @@
bnBestChainWork = pindexNew->bnChainWork;
nTimeBestReceived = GetTime();
nTransactionsUpdated++;
- printf("SetBestChain: new best=%s height=%d work=%s\n", hashBestChain.ToString().substr(0,20).c_str(), nBestHeight, bnBestChainWork.ToString().c_str());
+ printf(SINF SBLK "chain tip %s at height %d\n", hashBestChain.ToString().c_str(), nBestHeight);
return true;
}
@@ -1181,12 +1213,12 @@
// Check for duplicate
uint256 hash = GetHash();
if (mapBlockIndex.count(hash))
- return error("AddToBlockIndex() : %s already exists", hash.ToString().substr(0,20).c_str());
+ return error(SBLK "block %s already exists in block index", hash.ToString().c_str());
// Construct new block index object
CBlockIndex* pindexNew = new CBlockIndex(nFile, nBlockPos, *this);
if (!pindexNew)
- return error("AddToBlockIndex() : new CBlockIndex failed");
+ return error(SBLK "block index initialization failed");
map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.insert(make_pair(hash, pindexNew)).first;
pindexNew->phashBlock = &((*mi).first);
map<uint256, CBlockIndex*>::iterator miPrev = mapBlockIndex.find(hashPrevBlock);
@@ -1232,35 +1264,36 @@
// Size limits
if (vtx.empty() || vtx.size() > MAX_BLOCK_SIZE || ::GetSerializeSize(*this, SER_NETWORK) > MAX_BLOCK_SIZE)
- return DoS(100, error("CheckBlock() : size limits failed"));
+ return DoS(100, error(SBLK "block %s size is out of range", GetHash().ToString().c_str()));
// Check proof of work matches claimed amount
- if (!CheckProofOfWork(GetHash(), nBits))
- return DoS(50, error("CheckBlock() : proof of work failed"));
+ uint256 hash = GetHash();
+ if (!CheckProofOfWork(hash, nBits))
+ return DoS(50, error(SBLK "block %s proof of work is invalid", hash.ToString().c_str()));
// Check timestamp
if (GetBlockTime() > GetAdjustedTime() + 2 * 60 * 60)
- return error("CheckBlock() : block timestamp too far in the future");
+ return error(SBLK "block %s timestamp is too far in the future", hash.ToString().c_str());
// First transaction must be coinbase, the rest must not be
if (vtx.empty() || !vtx[0].IsCoinBase())
- return DoS(100, error("CheckBlock() : first tx is not coinbase"));
+ return DoS(100, error(SBLK "block %s first tx is not a coinbase tx", hash.ToString().c_str()));
for (int i = 1; i < vtx.size(); i++)
if (vtx[i].IsCoinBase())
- return DoS(100, error("CheckBlock() : more than one coinbase"));
+ return DoS(100, error(SBLK "block %s has more than one coinbase tx", hash.ToString().c_str()));
// Check transactions
BOOST_FOREACH(const CTransaction& tx, vtx)
if (!tx.CheckTransaction())
- return DoS(tx.nDoS, error("CheckBlock() : CheckTransaction failed"));
+ return DoS(tx.nDoS, error(SBLK "block %s tx check failed", hash.ToString().c_str()));
// Check that it's not full of nonstandard transactions
if (GetSigOpCount() > MAX_BLOCK_SIGOPS)
- return DoS(100, error("CheckBlock() : out-of-bounds SigOpCount"));
+ return DoS(100, error(SBLK "block %s sigopt count out of range", hash.ToString().c_str()));
// Check merkleroot
if (hashMerkleRoot != BuildMerkleTree())
- return DoS(100, error("CheckBlock() : hashMerkleRoot mismatch"));
+ return DoS(100, error(SBLK "block %s merkle root hash mistmatch", hash.ToString().c_str()));
return true;
}
@@ -1270,41 +1303,42 @@
// Check for duplicate
uint256 hash = GetHash();
if (mapBlockIndex.count(hash))
- return error("AcceptBlock() : block already in mapBlockIndex");
+ return error(SBLK "block %s already in block index", hash.ToString().c_str());
// Get prev block index
map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(hashPrevBlock);
if (mi == mapBlockIndex.end())
- return DoS(10, error("AcceptBlock() : prev block not found"));
+ return DoS(10, error(SBLK "block %s not found in index",
+ hashPrevBlock.ToString().c_str()));
CBlockIndex* pindexPrev = (*mi).second;
int nHeight = pindexPrev->nHeight+1;
// Check proof of work
if (nBits != GetNextWorkRequired(pindexPrev, this))
- return DoS(100, error("AcceptBlock() : incorrect proof of work"));
+ return DoS(100, error(SBLK "block %s proof of work is invalid", hash.ToString().c_str()));
// Check timestamp against prev
if (GetBlockTime() <= pindexPrev->GetMedianTimePast())
- return error("AcceptBlock() : block's timestamp is too early");
+ return error(SBLK "block %s timestamp is too early", hash.ToString().c_str());
// Check that all transactions are finalized
BOOST_FOREACH(const CTransaction& tx, vtx)
if (!tx.IsFinal(nHeight, GetBlockTime()))
- return DoS(10, error("AcceptBlock() : contains a non-final transaction"));
+ return DoS(10, error(SBLK "block %s contains a non-final tx", hash.ToString().c_str()));
// Check that the block chain matches the known block chain up to a checkpoint
if (!Checkpoints::CheckBlock(nHeight, hash))
- return DoS(100, error("AcceptBlock() : rejected by checkpoint lockin at %d", nHeight));
+ return DoS(100, error(SBLK "block %s rejected by checkpoint locking at height %d", hash.ToString().c_str(), nHeight));
// Write block to history file
if (!CheckDiskSpace(::GetSerializeSize(*this, SER_DISK)))
- return error("AcceptBlock() : out of disk space");
+ return error(SBLK "block %s writing to disk failure due out of space", hash.ToString().c_str());
unsigned int nFile = -1;
unsigned int nBlockPos = 0;
if (!WriteToDisk(nFile, nBlockPos))
- return error("AcceptBlock() : WriteToDisk failed");
+ return error(SBLK "block %s writing to disk failure", hash.ToString().c_str());
if (!AddToBlockIndex(nFile, nBlockPos))
- return error("AcceptBlock() : AddToBlockIndex failed");
+ return error(SBLK "block %s write to block index failure", hash.ToString().c_str());
// Relay inventory, but don't relay old inventory during initial block download
if (hashBestChain == hash)
@@ -1321,11 +1355,12 @@
// Check for duplicate
uint256 hash = pblock->GetHash();
if (mapBlockIndex.count(hash))
- return error("ProcessBlock() : already have block %d %s", mapBlockIndex[hash]->nHeight, hash.ToString().substr(0,20).c_str());
+ return error(SBLK "block %s already in index at height %d",
+ hash.ToString().c_str(), mapBlockIndex[hash]->nHeight);
// Preliminary checks
if (!pblock->CheckBlock())
- return error("ProcessBlock() : CheckBlock FAILED");
+ return error(SBLK "block %s check failed", hash.ToString().c_str());
CBlockIndex* pcheckpoint = Checkpoints::GetLastCheckpoint(mapBlockIndex);
if (pcheckpoint && pblock->hashPrevBlock != hashBestChain)
@@ -1336,7 +1371,8 @@
{
if (pfrom)
pfrom->Misbehaving(100);
- return error("ProcessBlock() : block with timestamp before last checkpoint");
+ return error(SBLK "block %s timestamp is lower than last checkpint",
+ hash.ToString().c_str());
}
CBigNum bnNewBlock;
bnNewBlock.SetCompact(pblock->nBits);
@@ -1346,14 +1382,16 @@
{
if (pfrom)
pfrom->Misbehaving(100);
- return error("ProcessBlock() : block with too little proof-of-work");
+ return error(SBLK "block %s proof-of-work is insufficient",
+ hash.ToString().c_str());
}
}
// If don't already have its previous block, throw it out!
if (!mapBlockIndex.count(pblock->hashPrevBlock))
{
- printf("ProcessBlock: BASTARD BLOCK, prev=%s, DISCARDED\n", pblock->hashPrevBlock.ToString().substr(0,20).c_str());
+ printf(SWAR SBLK "found bastard block %s referencing previous block %s, will now be discarded\n",
+ hash.ToString().c_str(), pblock->hashPrevBlock.ToString().c_str());
// Ask this guy to fill in what we're missing
if (pfrom)
@@ -1364,9 +1402,9 @@
// Store to disk
if (!pblock->AcceptBlock())
- return error("ProcessBlock() : AcceptBlock FAILED");
+ return error(SBLK "block %s rejected", hash.ToString().c_str());
- printf("ProcessBlock: ACCEPTED\n");
+ printf(SINF SBLK "block %s accepted\n", hash.ToString().c_str());
return true;
}
@@ -1385,10 +1423,7 @@
if (nFreeBytesAvailable < (uint64)15000000 + nAdditionalBytes)
{
fShutdown = true;
- string strMessage = _("Warning: Disk space is low ");
- strMiscWarning = strMessage;
- printf("*** %s\n", strMessage.c_str());
- ThreadSafeMessageBox(strMessage, "Bitcoin", wxOK | wxICON_EXCLAMATION);
+ printf(SWAR SPRC "disk space low\n");
CreateThread(Shutdown, NULL);
return false;
}
@@ -1479,9 +1514,9 @@
block.nNonce = 2083236893;
//// debug print
- printf("%s\n", block.GetHash().ToString().c_str());
- printf("%s\n", hashGenesisBlock.ToString().c_str());
- printf("%s\n", block.hashMerkleRoot.ToString().c_str());
+ printf(SINF SBLK "loaded genesis block %s\n", block.GetHash().ToString().c_str());
+ printf(SINF SBLK "block hash should be %s\n", hashGenesisBlock.ToString().c_str());
+ printf(SINF SBLK "merkle root is %s\n", block.hashMerkleRoot.ToString().c_str());
assert(block.hashMerkleRoot == uint256("0x4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"));
block.print();
assert(block.GetHash() == hashGenesisBlock);
@@ -1490,9 +1525,9 @@
unsigned int nFile;
unsigned int nBlockPos;
if (!block.WriteToDisk(nFile, nBlockPos))
- return error("LoadBlockIndex() : writing genesis block to disk failed");
+ return error(SBLK "genesis block writing to disk failure");
if (!block.AddToBlockIndex(nFile, nBlockPos))
- return error("LoadBlockIndex() : genesis block not accepted");
+ return error(SBLK "genesis block rejected");
}
return true;
@@ -1549,7 +1584,7 @@
pindex->nHeight,
pindex->nFile,
pindex->nBlockPos,
- block.GetHash().ToString().substr(0,20).c_str(),
+ block.GetHash().ToString().c_str(),
DateTimeStrFormat("%x %H:%M:%S", block.GetBlockTime()).c_str(),
block.vtx.size());
@@ -1641,12 +1676,11 @@
static map<unsigned int, vector<unsigned char> > mapReuseKey;
RandAddSeedPerfmon();
if (fDebug) {
- printf("%s ", DateTimeStrFormat("%x %H:%M:%S", GetTime()).c_str());
- printf("received: %s (%d bytes)\n", strCommand.c_str(), vRecv.size());
+ printf(SINF SNET "received %s (%d bytes)\n", strCommand.c_str(), vRecv.size());
}
if (mapArgs.count("-dropmessagestest") && GetRand(atoi(mapArgs["-dropmessagestest"])) == 0)
{
- printf("dropmessagestest DROPPING RECV MESSAGE\n");
+ printf(SWAR SNET "dropping test message\n");
return true;
}
@@ -1683,7 +1717,7 @@
// Disconnect if we connected to ourself
if (nNonce == nLocalHostNonce && nNonce > 1)
{
- printf("connected to self at %s, disconnecting\n", pfrom->addr.ToString().c_str());
+ printf(SINF SNET "connected to self at %s, disconnecting\n", pfrom->addr.ToString().c_str());
pfrom->fDisconnect = true;
return true;
}
@@ -1733,7 +1767,7 @@
pfrom->fSuccessfullyConnected = true;
- printf("version message: version %d, blocks=%d\n", pfrom->nVersion, pfrom->nStartingHeight);
+ printf(SINF SNET "received version %d, height %d\n", pfrom->nVersion, pfrom->nStartingHeight);
cPeerBlockCounts.input(pfrom->nStartingHeight);
}
@@ -1766,7 +1800,7 @@
if (vAddr.size() > 1000)
{
pfrom->Misbehaving(20);
- return error("message addr size() = %d", vAddr.size());
+ return error(SNET "addr message size out of range. (%d)", vAddr.size());
}
// Store the new addresses
@@ -1827,7 +1861,7 @@
if (vInv.size() > 50000)
{
pfrom->Misbehaving(20);
- return error("message inv size() = %d", vInv.size());
+ return error(SNET "inv message size out of range. (%d)", vInv.size());
}
CTxDB txdb("r");
@@ -1839,7 +1873,8 @@
bool fAlreadyHave = AlreadyHave(txdb, inv);
if (fDebug)
- printf(" got inventory: %s %s\n", inv.ToString().c_str(), fAlreadyHave ? "have" : "new");
+ printf(SINF SNET "received%s: %s\n",
+ fAlreadyHave ? " already seen" : " new", inv.ToString().c_str());
if (!fAlreadyHave)
pfrom->AskFor(inv);
@@ -1857,14 +1892,14 @@
if (vInv.size() > 50000)
{
pfrom->Misbehaving(20);
- return error("message getdata size() = %d", vInv.size());
+ return error(SNET "getdata message size out of range. (%d)", vInv.size());
}
BOOST_FOREACH(const CInv& inv, vInv)
{
if (fShutdown)
return true;
- printf("received getdata for: %s\n", inv.ToString().c_str());
+ printf(SINF SNET "received getdata %s\n", inv.ToString().c_str());
if (inv.type == MSG_BLOCK)
{
@@ -1902,7 +1937,8 @@
else
{
pfrom->Misbehaving(100);
- return error("BANNED peer issuing unknown inv type.");
+ return error(SNET "peer %s banned for issuing unknown inv message type",
+ pfrom->addr.ToString().c_str());
}
// Track requests for our stuff
@@ -1925,12 +1961,14 @@
pindex = pindex->pnext;
int nLimit = 500 + locator.GetDistanceBack();
unsigned int nBytes = 0;
- printf("getblocks %d to %s limit %d\n", (pindex ? pindex->nHeight : -1), hashStop.ToString().substr(0,20).c_str(), nLimit);
+ printf(SINF SNET "received getblocks height %d, block %s, limit %d\n",
+ (pindex ? pindex->nHeight : -1), hashStop.ToString().c_str(), nLimit);
for (; pindex; pindex = pindex->pnext)
{
if (pindex->GetBlockHash() == hashStop)
{
- printf(" getblocks stopping at %d %s (%u bytes)\n", pindex->nHeight, pindex->GetBlockHash().ToString().substr(0,20).c_str(), nBytes);
+ printf(SINF SNET "getblocks response stopping on block %s at height %d. (%u bytes)\n",
+ pindex->GetBlockHash().ToString().c_str(), pindex->nHeight, nBytes);
break;
}
pfrom->PushInventory(CInv(MSG_BLOCK, pindex->GetBlockHash()));
@@ -1941,7 +1979,8 @@
{
// 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 (%u bytes)\n", pindex->nHeight, pindex->GetBlockHash().ToString().substr(0,20).c_str(), nBytes);
+ printf(SINF SNET "getblocks response stopping on block %s at height %d. (%u bytes)\n",
+ pindex->nHeight, pindex->GetBlockHash().ToString().c_str(), nBytes);
pfrom->hashContinue = pindex->GetBlockHash();
break;
}
@@ -1974,7 +2013,8 @@
vector<CBlock> vHeaders;
int nLimit = 2000 + locator.GetDistanceBack();
- printf("getheaders %d to %s limit %d\n", (pindex ? pindex->nHeight : -1), hashStop.ToString().substr(0,20).c_str(), nLimit);
+ printf(SINF SNET "received getheaders height %d, block %s, limit %d\n",
+ (pindex ? pindex->nHeight : -1), hashStop.ToString().c_str(), nLimit);
for (; pindex; pindex = pindex->pnext)
{
vHeaders.push_back(pindex->GetBlockHeader());
@@ -2005,7 +2045,7 @@
}
else if (fMissingInputs)
{
- printf("REJECTED orphan tx %s\n", inv.hash.ToString().substr(0,10).c_str());
+ printf(SWAR SNET "tx %s rejected as orphan\n", inv.hash.ToString().c_str());
}
if (tx.nDoS) pfrom->Misbehaving(tx.nDoS);
}
@@ -2016,7 +2056,7 @@
CBlock block;
vRecv >> block;
- printf("received block %s\n", block.GetHash().ToString().substr(0,20).c_str());
+ printf(SINF SNET "received block %s\n", block.GetHash().ToString().c_str());
// block.print();
CInv inv(MSG_BLOCK, block.GetHash());
@@ -2108,7 +2148,8 @@
{
// He who comes to us with a turd, by the turd shall perish.
pfrom->Misbehaving(100);
- return error("BANNED peer issuing heathen command.");
+ return error(SNET "peer %s banned for issuing unknown message",
+ pfrom->addr.ToString().c_str());
}
@@ -2147,13 +2188,13 @@
{
if (vRecv.size() > nHeaderSize)
{
- printf("\n\nPROCESSMESSAGE MESSAGESTART NOT FOUND\n\n");
+ printf(SWAR SNET "message start couldn't be found while processing message\n");
vRecv.erase(vRecv.begin(), vRecv.end() - nHeaderSize);
}
break;
}
if (pstart - vRecv.begin() > 0)
- printf("\n\nPROCESSMESSAGE SKIPPED %d BYTES\n\n", pstart - vRecv.begin());
+ printf(SWAR SNET "skipped %d bytes while processing message\n", pstart - vRecv.begin());
vRecv.erase(vRecv.begin(), pstart);
// Read header
@@ -2162,7 +2203,7 @@
vRecv >> hdr;
if (!hdr.IsValid())
{
- printf("\n\nPROCESSMESSAGE: ERRORS IN HEADER %s\n\n\n", hdr.GetCommand().c_str());
+ printf(SERR SNET "errors found in message %s header while processing message\n", hdr.GetCommand().c_str());
continue;
}
string strCommand = hdr.GetCommand();
@@ -2171,7 +2212,7 @@
unsigned int nMessageSize = hdr.nMessageSize;
if (nMessageSize > MAX_SIZE)
{
- printf("ProcessMessage(%s, %u bytes) : nMessageSize > MAX_SIZE\n", strCommand.c_str(), nMessageSize);
+ printf(SERR SNET "message %s size out of range. (%u bytes)\n", strCommand.c_str(), nMessageSize);
continue;
}
if (nMessageSize > vRecv.size())
@@ -2189,8 +2230,9 @@
memcpy(&nChecksum, &hash, sizeof(nChecksum));
if (nChecksum != hdr.nChecksum)
{
- printf("ProcessMessage(%s, %u bytes) : CHECKSUM ERROR nChecksum=%08x hdr.nChecksum=%08x\n",
- strCommand.c_str(), nMessageSize, nChecksum, hdr.nChecksum);
+ printf(SERR SNET "message %s checksum error while processing message"
+ " (%u bytes, checksum %08x, header checksum %08x)\n",
+ strCommand.c_str(), nMessageSize, nChecksum, hdr.nChecksum);
continue;
}
}
@@ -2213,12 +2255,15 @@
if (strstr(e.what(), "end of data"))
{
// Allow exceptions from underlength message on vRecv
- printf("ProcessMessage(%s, %u bytes) : Exception '%s' caught, normally caused by a message being shorter than its stated length\n", strCommand.c_str(), nMessageSize, e.what());
+ printf(SERR SNET "message %s caught exception '%s' while processing message,"
+ " normally caused by a message being shorter than its stated length. (%u bytes)\n",
+ strCommand.c_str(), e.what(), nMessageSize);
}
else if (strstr(e.what(), "size too large"))
{
// Allow exceptions from overlong size
- printf("ProcessMessage(%s, %u bytes) : Exception '%s' caught\n", strCommand.c_str(), nMessageSize, e.what());
+ printf(SERR SNET "message %s caught exception '%s' while processing message. (%u bytes)\n",
+ strCommand.c_str(), e.what(), nMessageSize);
}
else
{
@@ -2232,7 +2277,7 @@
}
if (!fRet)
- printf("ProcessMessage(%s, %u bytes) FAILED\n", strCommand.c_str(), nMessageSize);
+ printf(SWAR SNET "failed to process message %s. (%u bytes)\n", strCommand.c_str(), nMessageSize);
}
vRecv.Compact();
@@ -2403,7 +2448,7 @@
const CInv& inv = (*pto->mapAskFor.begin()).second;
if (!AlreadyHave(txdb, inv))
{
- printf("sending getdata: %s\n", inv.ToString().c_str());
+ printf(SINF SNET "sending getdata %s\n", inv.ToString().c_str());
vGetData.push_back(inv);
if (vGetData.size() >= 1000)
{
@@ -2595,7 +2640,8 @@
dPriority += (double)nValueIn * nConf;
if (fDebug && GetBoolArg("-printpriority"))
- printf("priority nValueIn=%-12I64d nConf=%-5d dPriority=%-20.1f\n", nValueIn, nConf, dPriority);
+ printf(SINF SMEM "priority: %-20.1f, tx inputs value: %-12I64d, confirmations: %-5d\n",
+ dPriority, nValueIn, nConf);
}
// Priority is sum(valuein * age) / txsize
@@ -2608,10 +2654,9 @@
if (fDebug && GetBoolArg("-printpriority"))
{
- printf("priority %-20.1f %s\n%s", dPriority, tx.GetHash().ToString().substr(0,10).c_str(), tx.ToString().c_str());
+ printf(SINF SMEM "tx %s priority is %-20.1f\n", tx.GetHash().ToString().c_str(), dPriority);
if (porphan)
porphan->print();
- printf("\n");
}
}
@@ -2750,17 +2795,15 @@
return false;
//// debug print
- printf("BitcoinMiner:\n");
- printf("proof-of-work found \n hash: %s \ntarget: %s\n", hash.GetHex().c_str(), hashTarget.GetHex().c_str());
+ printf(SINF SMIN "miner found proof-of-work %s with target %s\n", hash.GetHex().c_str(), hashTarget.GetHex().c_str());
pblock->print();
- printf("%s ", DateTimeStrFormat("%x %H:%M", GetTime()).c_str());
- printf("generated %s\n", FormatMoney(pblock->vtx[0].vout[0].nValue).c_str());
+ printf(SINF SMIN "miner generated %s bitcoin\n", FormatMoney(pblock->vtx[0].vout[0].nValue).c_str());
// Found a solution
CRITICAL_BLOCK(cs_main)
{
if (pblock->hashPrevBlock != hashBestChain)
- return error("BitcoinMiner : generated block is stale");
+ return error(SMIN "miner generated a stale block %s", hash.ToString().c_str());
// Remove key from key pool
reservekey.KeepKey();
@@ -2771,7 +2814,7 @@
// Process this block the same as if we had received it from another node
if (!ProcessBlock(NULL, pblock))
- return error("BitcoinMiner : ProcessBlock, block not accepted");
+ return error(SMIN "miner rejected block %s", hash.ToString().c_str());
}
return true;
@@ -2781,7 +2824,7 @@
void static BitcoinMiner(CWallet *pwallet)
{
- printf("BitcoinMiner started\n");
+ printf(SINF SMIN "miner started\n");
SetThreadPriority(THREAD_PRIORITY_LOWEST);
// Each thread has its own key and counter
@@ -2815,7 +2858,7 @@
return;
IncrementExtraNonce(pblock.get(), pindexPrev, nExtraNonce);
- printf("Running BitcoinMiner with %d transactions in block\n", pblock->vtx.size());
+ printf(SINF SMIN "miner running with %d transactions in block\n", pblock->vtx.size());
//
@@ -2941,7 +2984,7 @@
nHPSTimerStart = 0;
if (vnThreadsRunning[3] == 0)
dHashesPerSec = 0;
- printf("ThreadBitcoinMiner exiting, %d threads remaining\n", vnThreadsRunning[3]);
+ printf(SINF SMIN "miner thread exiting, %d threads remaining\n", vnThreadsRunning[3]);
}
@@ -2956,17 +2999,17 @@
if (fGenerateBitcoins)
{
int nProcessors = boost::thread::hardware_concurrency();
- printf("%d processors\n", nProcessors);
+ printf(SINF SMIN "miner using %d processors\n", nProcessors);
if (nProcessors < 1)
nProcessors = 1;
if (fLimitProcessors && nProcessors > nLimitProcessors)
nProcessors = nLimitProcessors;
int nAddThreads = nProcessors - vnThreadsRunning[3];
- printf("Starting %d BitcoinMiner threads\n", nAddThreads);
+ printf(SINF SMIN "miner starting %d threads\n", nAddThreads);
for (int i = 0; i < nAddThreads; i++)
{
if (!CreateThread(ThreadBitcoinMiner, pwallet))
- printf("Error: CreateThread(ThreadBitcoinMiner) failed\n");
+ printf(SERR SMIN "miner can't create thread\n");
Sleep(10);
}
}
diff -uNr a/bitcoin/src/main.h b/bitcoin/src/main.h
--- a/bitcoin/src/main.h ff2bf8f8147dd8df5e1ef1bcea9b0159d3f83c1e30befef56415b99305aa99161ac1c05efb48be87a383ffb6d621fd3761bfb3e4952ca244a6e1398ca3c71dc6
+++ b/bitcoin/src/main.h 9e438ffcc2c67d60ad299e6b1e269d00cb08a629d2e6fe169039b1fad32421e28ef0c6286fc7e53dc5e069d6d20f715e885f83b5929849d7a997daaf2e59af8a
@@ -497,10 +497,10 @@
{
BOOST_FOREACH(const CTxIn& txin, vin)
if (!txin.scriptSig.IsPushOnly())
- return error("nonstandard txin: %s", txin.scriptSig.ToString().c_str());
+ return error(SMEM "non-standard input %s", txin.scriptSig.ToString().c_str());
BOOST_FOREACH(const CTxOut& txout, vout)
if (!::IsStandard(txout.scriptPubKey))
- return error("nonstandard txout: %s", txout.scriptPubKey.ToString().c_str());
+ return error(SMEM "non-standard output %s", txout.scriptPubKey.ToString().c_str());
return true;
}
@@ -573,18 +573,20 @@
{
CAutoFile filein = OpenBlockFile(pos.nFile, 0, pfileRet ? "rb+" : "rb");
if (!filein)
- return error("CTransaction::ReadFromDisk() : OpenBlockFile failed");
+ return error(SBLK "failure reading block file %d from disk", pos.nFile);
// Read transaction
if (fseek(filein, pos.nTxPos, SEEK_SET) != 0)
- return error("CTransaction::ReadFromDisk() : fseek failed");
+ return error(SBLK "failure reading block file %d from disk at position %d",
+ pos.nFile, pos.nTxPos);
filein >> *this;
// Return file pointer
if (pfileRet)
{
if (fseek(filein, pos.nTxPos, SEEK_SET) != 0)
- return error("CTransaction::ReadFromDisk() : second fseek failed");
+ return error(SBLK "second failure reading block file %d from disk at position %d",
+ pos.nFile, pos.nTxPos);
*pfileRet = filein.release();
}
return true;
@@ -906,7 +908,7 @@
// Open history file to append
CAutoFile fileout = AppendBlockFile(nFileRet);
if (!fileout)
- return error("CBlock::WriteToDisk() : AppendBlockFile failed");
+ return error(SBLK "failure wrting block file %d to disk", nFileRet);
// Write index header
unsigned int nSize = fileout.GetSerializeSize(*this);
diff -uNr a/bitcoin/src/net.cpp b/bitcoin/src/net.cpp
--- a/bitcoin/src/net.cpp 31eb2cbdf4f83f10ae8a7cdd3a69312ba6eafbecfafbeddf7546ce99847bd4f2a674037e2b89a0a7b91c37127d9770501c265a7977edb0ae0b3a5964272692f9
+++ b/bitcoin/src/net.cpp f2413ebc07b49f7a4cb96e4ae82bca531b78e4afe6b2c93be4e00a9c89813cfbb62b0f255dde13ee6e59f883936afc2640b139e49ea7a766868cdb9edc2cd3db
@@ -111,33 +111,33 @@
int nRet = select(hSocket + 1, NULL, &fdset, NULL, &timeout);
if (nRet == 0)
{
- printf("connection timeout\n");
+ printf(SERR SNET "connection timeout\n");
closesocket(hSocket);
return false;
}
if (nRet == SOCKET_ERROR)
{
- printf("select() for connection failed: %i\n",WSAGetLastError());
+ printf(SERR SNET "select connection failed: %i\n", WSAGetLastError());
closesocket(hSocket);
return false;
}
socklen_t nRetSize = sizeof(nRet);
if (getsockopt(hSocket, SOL_SOCKET, SO_ERROR, &nRet, &nRetSize) == SOCKET_ERROR)
{
- printf("getsockopt() for connection failed: %i\n",WSAGetLastError());
+ printf(SERR SNET "getsockopt for connection failed: %i\n", WSAGetLastError());
closesocket(hSocket);
return false;
}
if (nRet != 0)
{
- printf("connect() failed after select(): %s\n",strerror(nRet));
+ printf(SERR SNET "connect failed after select: %s\n", strerror(nRet));
closesocket(hSocket);
return false;
}
}
else
{
- printf("connect() failed: %i\n",WSAGetLastError());
+ printf(SERR SNET "connect failed: %i\n", WSAGetLastError());
closesocket(hSocket);
return false;
}
@@ -157,7 +157,7 @@
if (fProxy)
{
- printf("proxy connecting %s\n", addrConnect.ToString().c_str());
+ printf(SWAR SNET "connecting through proxy to %s\n", addrConnect.ToString().c_str());
char pszSocks4IP[] = "\4\1\0\0\0\0\0\0user";
memcpy(pszSocks4IP + 2, &addrConnect.port, 2);
memcpy(pszSocks4IP + 4, &addrConnect.ip, 4);
@@ -168,22 +168,24 @@
if (ret != nSize)
{
closesocket(hSocket);
- return error("Error sending to proxy");
+ return error(SNET "couldn't send message over proxy address %s",
+ addrConnect.ToString().c_str());
}
char pchRet[8];
if (recv(hSocket, pchRet, 8, 0) != 8)
{
closesocket(hSocket);
- return error("Error reading proxy response");
+ return error(SNET "couldn't read response over proxy address %s",
+ addrConnect.ToString().c_str());
}
if (pchRet[1] != 0x5a)
{
closesocket(hSocket);
if (pchRet[1] != 0x5b)
- printf("ERROR: Proxy returned error %d\n", pchRet[1]);
+ printf(SERR SNET "proxy returned error %d\n", pchRet[1]);
return false;
}
- printf("proxy connected %s\n", addrConnect.ToString().c_str());
+ printf(SWAR SNET "connected through proxy to %s\n", addrConnect.ToString().c_str());
}
hSocketRet = hSocket;
@@ -260,7 +262,7 @@
if (it == mapAddresses.end())
{
// New address
- printf("AddAddress(%s)\n", addr.ToString().c_str());
+ printf(SINF SADR "adding %s\n", addr.ToString().c_str());
mapAddresses.insert(make_pair(addr.GetKey(), addr));
fUpdated = true;
fNew = true;
@@ -469,7 +471,7 @@
}
/// debug print
- printf("trying connection %s lastseen=%.1fhrs lasttry=%.1fhrs\n",
+ printf(SINF SNET "trying to connect to %s\n",
addrConnect.ToString().c_str(),
(double)(addrConnect.nTime - GetAdjustedTime())/3600.0,
(double)(addrConnect.nLastTry - GetAdjustedTime())/3600.0);
@@ -482,11 +484,11 @@
if (ConnectSocket(addrConnect, hSocket))
{
/// debug print
- printf("connected %s\n", addrConnect.ToString().c_str());
+ printf(SINF SNET "connected to %s\n", addrConnect.ToString().c_str());
// Set to nonblocking
if (fcntl(hSocket, F_SETFL, O_NONBLOCK) == SOCKET_ERROR)
- printf("ConnectSocket() : fcntl nonblocking setting failed, error %d\n", errno);
+ printf(SERR SNET "socket fcntl nonblocking setting failed, error %d\n", errno);
// Add node
CNode* pnode = new CNode(hSocket, addrConnect, false);
@@ -511,9 +513,7 @@
fDisconnect = true;
if (hSocket != INVALID_SOCKET)
{
- if (fDebug)
- printf("%s ", DateTimeStrFormat("%x %H:%M:%S", GetTime()).c_str());
- printf("disconnecting node %s\n", addr.ToString().c_str());
+ printf(SWAR SNET "disconnecting from node %s\n", addr.ToString().c_str());
closesocket(hSocket);
hSocket = INVALID_SOCKET;
}
@@ -559,7 +559,7 @@
{
if (addr.IsLocal())
{
- printf("Warning: local node %s misbehaving\n", addr.ToString().c_str());
+ printf(SWAR SNET "local node %s is misbehaving\n", addr.ToString().c_str());
return false;
}
@@ -604,12 +604,12 @@
vnThreadsRunning[0]--;
throw; // support pthread_cancel()
}
- printf("ThreadSocketHandler exiting\n");
+ printf(SWAR SNET "socket handling thread exiting\n");
}
void ThreadSocketHandler2(void* parg)
{
- printf("ThreadSocketHandler started\n");
+ printf(SINF SNET "socket handling thread started\n");
list<CNode*> vNodesDisconnected;
int nPrevNodeCount = 0;
@@ -713,7 +713,7 @@
int nErr = WSAGetLastError();
if (hSocketMax > -1)
{
- printf("socket select error %d\n", nErr);
+ printf(SERR SNET "socket select error %d\n", nErr);
for (int i = 0; i <= hSocketMax; i++)
FD_SET(i, &fdsetRecv);
}
@@ -745,7 +745,7 @@
if (hSocket == INVALID_SOCKET)
{
if (WSAGetLastError() != WSAEWOULDBLOCK)
- printf("socket error accept failed: %d\n", WSAGetLastError());
+ printf(SERR SNET "socket error accept failed: %d\n", WSAGetLastError());
}
else if (nInbound >= GetArg("-maxconnections", 125) - MAX_OUTBOUND_CONNECTIONS)
{
@@ -753,12 +753,12 @@
}
else if (CNode::IsBanned(addr.ip))
{
- printf("connection from %s dropped (banned)\n", addr.ToString().c_str());
+ printf(SWAR SNET "connection from %s dropped. (banned)\n", addr.ToString().c_str());
closesocket(hSocket);
}
else
{
- printf("accepted connection %s\n", addr.ToString().c_str());
+ printf(SINF SNET "accepted connection to %s\n", addr.ToString().c_str());
CNode* pnode = new CNode(hSocket, addr, true);
pnode->AddRef();
CRITICAL_BLOCK(cs_vNodes)
@@ -796,7 +796,7 @@
if (nPos > ReceiveBufferSize()) {
if (!pnode->fDisconnect)
- printf("socket recv flood control disconnect (%d bytes)\n", vRecv.size());
+ printf(SWAR SNET "socket received flood, disconnecting. (%d bytes)\n", vRecv.size());
pnode->CloseSocketDisconnect();
}
else {
@@ -813,7 +813,7 @@
{
// socket closed gracefully
if (!pnode->fDisconnect)
- printf("socket closed\n");
+ printf(SWAR SNET "socket closed\n");
pnode->CloseSocketDisconnect();
}
else if (nBytes < 0)
@@ -823,7 +823,7 @@
if (nErr != WSAEWOULDBLOCK && nErr != WSAEMSGSIZE && nErr != WSAEINTR && nErr != WSAEINPROGRESS)
{
if (!pnode->fDisconnect)
- printf("socket recv error %d\n", nErr);
+ printf(SERR SNET "socket received error %d\n", nErr);
pnode->CloseSocketDisconnect();
}
}
@@ -855,13 +855,13 @@
int nErr = WSAGetLastError();
if (nErr != WSAEWOULDBLOCK && nErr != WSAEMSGSIZE && nErr != WSAEINTR && nErr != WSAEINPROGRESS)
{
- printf("socket send error %d\n", nErr);
+ printf(SERR SNET "socket send error %d\n", nErr);
pnode->CloseSocketDisconnect();
}
}
if (vSend.size() > SendBufferSize()) {
if (!pnode->fDisconnect)
- printf("socket send flood control disconnect (%d bytes)\n", vSend.size());
+ printf(SWAR SNET "socket send flood, disconnecting. (%d bytes)\n", vSend.size());
pnode->CloseSocketDisconnect();
}
}
@@ -877,17 +877,17 @@
{
if (pnode->nLastRecv == 0 || pnode->nLastSend == 0)
{
- printf("socket no message in first 60 seconds, %d %d\n", pnode->nLastRecv != 0, pnode->nLastSend != 0);
+ printf(SWAR SNET "socket received no message in first 60 seconds, disconnecting\n");
pnode->fDisconnect = true;
}
else if (GetTime() - pnode->nLastSend > 90*60 && GetTime() - pnode->nLastSendEmpty > 90*60)
{
- printf("socket not sending\n");
+ printf(SWAR SNET "socket not sending, disconnecting\n");
pnode->fDisconnect = true;
}
else if (GetTime() - pnode->nLastRecv > 90*60)
{
- printf("socket inactivity timeout\n");
+ printf(SWAR SNET "socket inactivity timeout, disconnecting\n");
pnode->fDisconnect = true;
}
}
@@ -919,12 +919,12 @@
vnThreadsRunning[1]--;
PrintException(NULL, "ThreadOpenConnections()");
}
- printf("ThreadOpenConnections exiting\n");
+ printf(SWAR SNET "connection opening thread exiting\n");
}
void ThreadOpenConnections2(void* parg)
{
- printf("ThreadOpenConnections started\n");
+ printf(SINF SNET "connection opening thread started\n");
// Connect to specific addresses
if (mapArgs.count("-connect"))
@@ -1107,12 +1107,12 @@
vnThreadsRunning[2]--;
PrintException(NULL, "ThreadMessageHandler()");
}
- printf("ThreadMessageHandler exiting\n");
+ printf(SWAR SNET "message handling thread exiting\n");
}
void ThreadMessageHandler2(void* parg)
{
- printf("ThreadMessageHandler started\n");
+ printf(SINF SNET "message handling thread starting\n");
SetThreadPriority(THREAD_PRIORITY_BELOW_NORMAL);
while (!fShutdown)
{
@@ -1177,8 +1177,7 @@
hListenSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
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());
+ printf(SERR SNET "couldn't open socket for incoming connections, error %d\n", WSAGetLastError());
return false;
}
@@ -1193,8 +1192,7 @@
if (fcntl(hListenSocket, F_SETFL, O_NONBLOCK) == SOCKET_ERROR)
{
- strError = strprintf("Error: Couldn't set properties on socket for incoming connections (error %d)", WSAGetLastError());
- printf("%s\n", strError.c_str());
+ printf(SERR SNET "couldn't set properties on socket for incoming connections, error %d\n", WSAGetLastError());
return false;
}
@@ -1209,19 +1207,17 @@
{
int nErr = WSAGetLastError();
if (nErr == WSAEADDRINUSE)
- strError = strprintf(_("Unable to bind to port %d on this computer. Bitcoin is probably already running."), ntohs(sockaddr.sin_port));
+ printf(SERR SNET "unable to bind to port %d, bitcoind is probably already running\n", ntohs(sockaddr.sin_port));
else
- strError = strprintf("Error: Unable to bind to port %d on this computer (bind returned error %d)", ntohs(sockaddr.sin_port), nErr);
- printf("%s\n", strError.c_str());
+ printf(SERR SNET "unable to bind to port %d, error %d\n", ntohs(sockaddr.sin_port), nErr);
return false;
}
- printf("Bound to port %d\n", ntohs(sockaddr.sin_port));
+ printf(SINF SNET "bound to port %d\n", ntohs(sockaddr.sin_port));
// 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());
+ printf(SERR SNET "listening for incoming connections failed, error %d", WSAGetLastError());
return false;
}
@@ -1248,7 +1244,7 @@
{
struct sockaddr_in* s4 = (struct sockaddr_in*)(ifa->ifa_addr);
if (inet_ntop(ifa->ifa_addr->sa_family, (void*)&(s4->sin_addr), pszIP, sizeof(pszIP)) != NULL)
- printf("ipv4 %s: %s\n", ifa->ifa_name, pszIP);
+ printf(SINF SNET "ipv4 address %s: %s\n", ifa->ifa_name, pszIP);
// Take the first IP that isn't loopback 127.x.x.x
CAddress addr(*(unsigned int*)&s4->sin_addr, GetListenPort(), nLocalServices);
@@ -1262,13 +1258,13 @@
{
struct sockaddr_in6* s6 = (struct sockaddr_in6*)(ifa->ifa_addr);
if (inet_ntop(ifa->ifa_addr->sa_family, (void*)&(s6->sin6_addr), pszIP, sizeof(pszIP)) != NULL)
- printf("ipv6 %s: %s\n", ifa->ifa_name, pszIP);
+ printf(SINF SNET "ipv6 address %s: %s\n", ifa->ifa_name, pszIP);
}
}
freeifaddrs(myaddrs);
}
- printf("addrLocalHost = %s\n", addrLocalHost.ToString().c_str());
+ printf(SINF SNET "local host address is %s\n", addrLocalHost.ToString().c_str());
if (fUseProxy || mapArgs.count("-connect") || fNoListen)
{
@@ -1284,7 +1280,7 @@
GetConfigFile().c_str()));
}
- printf("addrLocalHost = %s\n", addrLocalHost.ToString().c_str());
+ printf(SINF SNET "local host address is %s\n", addrLocalHost.ToString().c_str());
//
// Start threads
@@ -1292,15 +1288,15 @@
// Send and receive from sockets, accept connections
if (!CreateThread(ThreadSocketHandler, NULL))
- printf("Error: CreateThread(ThreadSocketHandler) failed\n");
+ printf(SERR SNET "can't create socket handling thread\n");
// Initiate outbound connections
if (!CreateThread(ThreadOpenConnections, NULL))
- printf("Error: CreateThread(ThreadOpenConnections) failed\n");
+ printf(SERR SNET "can't create connection opening thread\n");
// Process messages
if (!CreateThread(ThreadMessageHandler, NULL))
- printf("Error: CreateThread(ThreadMessageHandler) failed\n");
+ printf(SERR SNET "can't create message handling thread\n");
// Generate coins in the background
GenerateBitcoins(fGenerateBitcoins, pwalletMain);
@@ -1308,7 +1304,7 @@
bool StopNode()
{
- printf("StopNode()\n");
+ printf(SWAR SNET "stopping node\n");
fShutdown = true;
nTransactionsUpdated++;
int64 nStart = GetTime();
@@ -1319,11 +1315,11 @@
break;
Sleep(20);
}
- if (vnThreadsRunning[0] > 0) printf("ThreadSocketHandler still running\n");
- if (vnThreadsRunning[1] > 0) printf("ThreadOpenConnections still running\n");
- if (vnThreadsRunning[2] > 0) printf("ThreadMessageHandler still running\n");
- if (vnThreadsRunning[3] > 0) printf("ThreadBitcoinMiner still running\n");
- if (vnThreadsRunning[4] > 0) printf("ThreadRPCServer still running\n");
+ if (vnThreadsRunning[0] > 0) printf(SWAR SNET "socket handling thread still running\n");
+ if (vnThreadsRunning[1] > 0) printf(SWAR SNET "connection opening thread still running\n");
+ if (vnThreadsRunning[2] > 0) printf(SWAR SNET "message handling thread still running\n");
+ if (vnThreadsRunning[3] > 0) printf(SWAR SMIN "miner thread still running\n");
+ if (vnThreadsRunning[4] > 0) printf(SWAR SNET "rpc server thread still running\n");
while (vnThreadsRunning[2] > 0 || vnThreadsRunning[4] > 0)
Sleep(20);
Sleep(50);
@@ -1345,7 +1341,7 @@
closesocket(pnode->hSocket);
if (hListenSocket != INVALID_SOCKET)
if (closesocket(hListenSocket) == SOCKET_ERROR)
- printf("closesocket(hListenSocket) failed with error %d\n", WSAGetLastError());
+ printf(SERR SNET "closing socket failed with error %d\n", WSAGetLastError());
}
}
diff -uNr a/bitcoin/src/net.h b/bitcoin/src/net.h
--- a/bitcoin/src/net.h bb842420bcc67752edf8e658524b135f499c5f8676557a6c12f47f204303e34bd73beabdf6e9146ba452947c4e5cd298529969fab90f16942f6bf0c1229f7043
+++ b/bitcoin/src/net.h f72c255497921a2dbc173565ec31179d1e5959fa3d0bc61313f6d0ac168f471ee79dce5ee92f51ee923daf2e8b1959b8368e066fd177ffcb5c57136a211bc2f0
@@ -261,7 +261,7 @@
// We're using mapAskFor as a priority queue,
// the key is the earliest time the request can be sent
int64& nRequestTime = mapAlreadyAskedFor[inv];
- printf("askfor %s %"PRI64d"\n", inv.ToString().c_str(), nRequestTime);
+ printf(SINF SNET "requesting inv %s\n", inv.ToString().c_str());
// Make sure not to reuse time indexes to keep things in the same order
int64 nNow = (GetTime() - 1) * 1000000;
@@ -286,8 +286,7 @@
vSend << CMessageHeader(pszCommand, 0);
nMessageStart = vSend.size();
if (fDebug) {
- printf("%s ", DateTimeStrFormat("%x %H:%M:%S", GetTime()).c_str());
- printf("sending: %s ", pszCommand);
+ printf(SINF SNET "sending command %s\n", pszCommand);
}
}
@@ -301,14 +300,14 @@
LEAVE_CRITICAL_SECTION(cs_vSend);
if (fDebug)
- printf("(aborted)\n");
+ printf(SWAR SNET "aborted\n");
}
void EndMessage()
{
if (mapArgs.count("-dropmessagestest") && GetRand(atoi(mapArgs["-dropmessagestest"])) == 0)
{
- printf("dropmessages DROPPING SEND MESSAGE\n");
+ printf(SWAR SNET "dropping send message\n");
AbortMessage();
return;
}
@@ -330,10 +329,6 @@
memcpy((char*)&vSend[nHeaderStart] + offsetof(CMessageHeader, nChecksum), &nChecksum, sizeof(nChecksum));
}
- if (fDebug) {
- printf("(%d bytes)\n", nSize);
- }
-
nHeaderStart = -1;
nMessageStart = -1;
LEAVE_CRITICAL_SECTION(cs_vSend);
diff -uNr a/bitcoin/src/protocol.cpp b/bitcoin/src/protocol.cpp
--- a/bitcoin/src/protocol.cpp 35effbc7f73cdbda92148be58171b2337c090a7997eb3b02daf9a88287b4315c80d7fa5edf403be9cf958969c0c7e0c1b578c10f146ee0ea9b2965a1f97971bf
+++ b/bitcoin/src/protocol.cpp e75f60d2fe430b9077aed4638530be81b51c558f5947c2cae6d7b90fbd1801ffe030c243684dfce754aa0a5c1810067b33a55526aaf7218b702f9aca67190586
@@ -68,7 +68,7 @@
// Message size
if (nMessageSize > MAX_SIZE)
{
- printf("CMessageHeader::IsValid() : (%s, %u bytes) nMessageSize > MAX_SIZE\n", GetCommand().c_str(), nMessageSize);
+ printf(SERR SNET "message %s size out of range. (%u bytes)\n", GetCommand().c_str(), nMessageSize);
return false;
}
diff -uNr a/bitcoin/src/script.cpp b/bitcoin/src/script.cpp
--- a/bitcoin/src/script.cpp e618531aaceecefe505689a76254da2cad45af6db44de26138e130b166d1d26b6a78d0ccf352b8c9c11878e5549010ce48b2083089e14ee026d949f06cd310f6
+++ b/bitcoin/src/script.cpp f04d064f0c465c43227ed87994690f7a4d6232ed62cefbea03fc90128c29041f077a8d5a8943094f65bdf565258611a25a9b7df32204233e533957a4ca6addf6
@@ -877,7 +877,7 @@
{
if (nIn >= txTo.vin.size())
{
- printf("ERROR: SignatureHash() : nIn=%d out of range\n", nIn);
+ printf(SERR SMEM "signature hash for input number %d out of range\n", nIn);
return 1;
}
CTransaction txTmp(txTo);
@@ -908,7 +908,7 @@
unsigned int nOut = nIn;
if (nOut >= txTmp.vout.size())
{
- printf("ERROR: SignatureHash() : nOut=%d out of range\n", nOut);
+ printf(SERR SMEM "signature hash for output number %d out of range\n", nOut);
return 1;
}
txTmp.vout.resize(nOut+1);
diff -uNr a/bitcoin/src/util.cpp b/bitcoin/src/util.cpp
--- a/bitcoin/src/util.cpp 737f20496467f30d16567d63d809fe08641d524903ae5eb425a9d209da2e9524195d7b3364bf723bce428621344cc6c4861c58d601bfcd93b2af50c537d5d038
+++ b/bitcoin/src/util.cpp 70bd2dee99f74cbb32f47c741cf0381341a892379c46734fb108109b65df2706694664ae63d69a9caf21c6fb43d551b2a5b0231bca6cf8561c962958cd310036
@@ -142,11 +142,14 @@
inline int OutputDebugStringF(const char* pszFormat, ...)
{
int ret = 0;
+ const char* isodt = GetISODateTime().c_str();
+
if (fPrintToConsole)
{
// print to console
va_list arg_ptr;
va_start(arg_ptr, pszFormat);
+ printf("%s ", isodt);
ret = vprintf(pszFormat, arg_ptr);
va_end(arg_ptr);
}
@@ -177,6 +180,7 @@
va_list arg_ptr;
va_start(arg_ptr, pszFormat);
+ fprintf(fileout, "%s ", isodt);
ret = vfprintf(fileout, pszFormat, arg_ptr);
va_end(arg_ptr);
}
@@ -246,7 +250,7 @@
ret = limit - 1;
buffer[limit-1] = 0;
}
- printf("ERROR: %s\n", buffer);
+ printf(SERR "%s\n", buffer);
return false;
}
@@ -806,7 +810,8 @@
if (vTimeOffsets.empty())
vTimeOffsets.push_back(0);
vTimeOffsets.push_back(nOffsetSample);
- printf("Added time data, samples %d, offset %+"PRI64d" (%+"PRI64d" minutes)\n", vTimeOffsets.size(), vTimeOffsets.back(), vTimeOffsets.back()/60);
+ printf(SINF SPRC "added time data, samples %d, offset %+"PRI64d". (%+"PRI64d" minutes)\n",
+ vTimeOffsets.size(), vTimeOffsets.back(), vTimeOffsets.back()/60);
if (vTimeOffsets.size() >= 5 && vTimeOffsets.size() % 2 == 1)
{
sort(vTimeOffsets.begin(), vTimeOffsets.end());
@@ -832,16 +837,10 @@
if (!fMatch)
{
fDone = true;
- string strMessage = _("Warning: Please check that your computer's date and time are correct. If your clock is wrong Bitcoin will not work properly.");
- strMiscWarning = strMessage;
- printf("*** %s\n", strMessage.c_str());
- boost::thread(boost::bind(ThreadSafeMessageBox, strMessage+" ", string("Bitcoin"), wxOK | wxICON_EXCLAMATION, (wxWindow*)NULL, -1, -1));
+ printf(SWAR SPRC "please check that your computer's date and time are correct\n");
}
}
}
- BOOST_FOREACH(int64 n, vTimeOffsets)
- printf("%+"PRI64d" ", n);
- printf("| nTimeOffset = %+"PRI64d" (%+"PRI64d" minutes)\n", nTimeOffset, nTimeOffset/60);
}
}
diff -uNr a/bitcoin/src/util.h b/bitcoin/src/util.h
--- a/bitcoin/src/util.h e217371b4da3b8f7b7fb1acd0b281f361de3854e91af884bf70cb39267075a6be1bb504dc9e4d3eebee60ecaf371ac8e83daf88f69569a14c53fb189c4871a9f
+++ b/bitcoin/src/util.h 922077b9a93594100c7cba97d32583565c2adb04c7b1d848a4200ffaf7c3d27bc6bc02643edefc709a7396e792e3697e4ca345b02f3054db4ac19adf530010bf
@@ -18,6 +18,7 @@
#include <boost/thread.hpp>
#include <boost/interprocess/sync/interprocess_recursive_mutex.hpp>
#include <boost/date_time/gregorian/gregorian_types.hpp>
+#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/date_time/posix_time/posix_time_types.hpp>
#include <openssl/sha.h>
@@ -37,6 +38,18 @@
#define ARRAYLEN(array) (sizeof(array)/sizeof((array)[0]))
#define printf OutputDebugStringF
+#define SERR "ERR "
+#define SWAR "WAR "
+#define SINF "INF "
+
+#define SPRC "PRC "
+#define SMEM "MEM "
+#define SADR "ADR "
+#define SBLK "BLK "
+#define SNET "NET "
+#define SWAL "WAL "
+#define SMIN "MIN "
+
#ifdef snprintf
#undef snprintf
#endif
@@ -373,6 +386,11 @@
boost::posix_time::ptime(boost::gregorian::date(1970,1,1))).total_milliseconds();
}
+inline std::string GetISODateTime() {
+ boost::posix_time::ptime ut = boost::posix_time::microsec_clock::universal_time();
+ return boost::posix_time::to_iso_extended_string(ut);
+}
+
inline std::string DateTimeStrFormat(const char* pszFormat, int64 nTime)
{
time_t n = nTime;
diff -uNr a/bitcoin/src/wallet.cpp b/bitcoin/src/wallet.cpp
--- a/bitcoin/src/wallet.cpp bdc4fc472be4a86fb91fa69368faace04414fdeee5b8c82795e31d37e21581b973caf7f3e9ccc27d487944a5782e3b59615180eab87c8b3e81242901f3039e4d
+++ b/bitcoin/src/wallet.cpp 1bbb78c44552bfb47b91bd1f5c9de6aea2021e1ef54be00ae6c57294747ac8ed888b2210909e804f4ca92da41bba35589123cdc09759fef2b96711a0985fd47b
@@ -92,7 +92,7 @@
if (pMasterKey.second.nDeriveIterations < 25000)
pMasterKey.second.nDeriveIterations = 25000;
- printf("Wallet passphrase changed to an nDeriveIterations of %i\n", pMasterKey.second.nDeriveIterations);
+ printf(SINF SWAL "passphrase changed through %i deriving iterations\n", pMasterKey.second.nDeriveIterations);
if (!crypter.SetKeyFromPassphrase(strNewWalletPassphrase, pMasterKey.second.vchSalt, pMasterKey.second.nDeriveIterations, pMasterKey.second.nDerivationMethod))
return false;
@@ -151,7 +151,7 @@
if (kMasterKey.nDeriveIterations < 25000)
kMasterKey.nDeriveIterations = 25000;
- printf("Encrypting Wallet with an nDeriveIterations of %i\n", kMasterKey.nDeriveIterations);
+ printf(SINF SWAL "encrypting using %i deriving iterations\n", kMasterKey.nDeriveIterations);
if (!crypter.SetKeyFromPassphrase(strWalletPassphrase, kMasterKey.vchSalt, kMasterKey.nDeriveIterations, kMasterKey.nDerivationMethod))
return false;
@@ -214,7 +214,7 @@
CWalletTx& wtx = (*mi).second;
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());
+ printf(SWAR SWAL "found spent %s bitcoin on tx %s\n", FormatMoney(wtx.GetCredit()).c_str(), wtx.GetHash().ToString().c_str());
wtx.MarkSpent(txin.prevout.n);
wtx.WriteToDisk();
vWalletUpdated.push_back(txin.prevout.hash);
@@ -261,7 +261,7 @@
}
//// debug print
- printf("AddToWallet %s %s%s\n", wtxIn.GetHash().ToString().substr(0,10).c_str(), (fInsertedNew ? "new" : ""), (fUpdated ? "update" : ""));
+ printf(SINF SWAL "adding input from tx %s. (%s)\n", wtxIn.GetHash().ToString().c_str(), (fInsertedNew ? "new, " : (fUpdated ? "update" : "")));
// Write to disk
if (fInsertedNew || fUpdated)
@@ -440,7 +440,7 @@
vector<unsigned char> vchPubKey;
if (!ExtractAddress(txout.scriptPubKey, NULL, address))
{
- printf("CWalletTx::GetAmounts: Unknown transaction type found, txid %s\n",
+ printf(SWAR SWAL "unknown transaction type found, tx %s\n",
this->GetHash().ToString().c_str());
address = " unknown ";
}
@@ -537,7 +537,7 @@
}
else
{
- printf("ERROR: AddSupportingTransactions() : unsupported transaction\n");
+ printf(SERR SWAL "unsupported tx\n");
continue;
}
@@ -605,7 +605,7 @@
// Update fSpent if a tx got spent somewhere else by a copy of wallet.dat
if (txindex.vSpent.size() != wtx.vout.size())
{
- printf("ERROR: ReacceptWalletTransactions() : txindex.vSpent.size() %d != wtx.vout.size() %d\n", txindex.vSpent.size(), wtx.vout.size());
+ printf(SERR SWAL "tx index spent count differs from output index length\n");
continue;
}
for (int i = 0; i < txindex.vSpent.size(); i++)
@@ -621,7 +621,8 @@
}
if (fUpdated)
{
- printf("ReacceptWalletTransactions found spent coin %sbc %s\n", FormatMoney(wtx.GetCredit()).c_str(), wtx.GetHash().ToString().c_str());
+ printf(SERR SWAL "found spent %s bitcoin on tx %s\n",
+ FormatMoney(wtx.GetCredit()).c_str(), wtx.GetHash().ToString().c_str());
wtx.MarkDirty();
wtx.WriteToDisk();
}
@@ -658,7 +659,7 @@
uint256 hash = GetHash();
if (!txdb.ContainsTx(hash))
{
- printf("Relaying wtx %s\n", hash.ToString().substr(0,10).c_str());
+ printf(SINF SWAL "relaying wallet tx %s\n", hash.ToString().c_str());
RelayMessage(CInv(MSG_TX, hash), (CTransaction)*this);
}
}
@@ -689,7 +690,7 @@
nLastTime = GetTime();
// Rebroadcast any of our txes that aren't in a block yet
- printf("ResendWalletTransactions()\n");
+ printf(SWAR SWAL "resending wallet txs\n");
CTxDB txdb("r");
CRITICAL_BLOCK(cs_wallet)
{
@@ -890,11 +891,11 @@
}
//// debug print
- printf("SelectCoins() best subset: ");
+ std::string str;
for (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());
+ str += FormatMoney(vValue[i].first) + (i == vValue.size() - 1 ? "" : " ");
+ printf(SINF SWAL "selecting best output subset: %s\n", str.c_str());
}
return true;
@@ -1041,7 +1042,7 @@
CRITICAL_BLOCK(cs_main)
CRITICAL_BLOCK(cs_wallet)
{
- printf("CommitTransaction:\n%s", wtxNew.ToString().c_str());
+ printf(SINF SWAL "commit tx %s\n", 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
@@ -1077,7 +1078,7 @@
if (!wtxNew.AcceptToMemoryPool())
{
// This must not fail. The transaction has already been signed and recorded.
- printf("CommitTransaction() : Error: Transaction not valid");
+ printf(SERR SWAL "tx found non-valid while commiting");
return false;
}
wtxNew.RelayWalletTransaction();
@@ -1097,17 +1098,19 @@
if (IsLocked())
{
string strError = _("Error: Wallet locked, unable to create transaction ");
- printf("SendMoney() : %s", strError.c_str());
+ printf(SERR SWAL "send money failed with error %s\n", strError.c_str());
return strError;
}
if (!CreateTransaction(scriptPubKey, nValue, wtxNew, reservekey, nFeeRequired))
{
string strError;
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());
+ strError += strprintf("tx requires a tx fee of at"
+ " least %s because of its amount, complexity, or use of recently"
+ " received funds", FormatMoney(nFeeRequired).c_str());
else
- strError = _("Error: Transaction creation failed ");
- printf("SendMoney() : %s", strError.c_str());
+ strError += strprintf("tx creation failed");
+ printf(SERR SWAL "send money failed with error: %s", strError.c_str());
return strError;
}
@@ -1205,10 +1208,10 @@
if (mapWallet.count(block.vtx[0].GetHash()))
{
CWalletTx& wtx = mapWallet[block.vtx[0].GetHash()];
- printf(" mine: %d %d %d", wtx.GetDepthInMainChain(), wtx.GetBlocksToMaturity(), wtx.GetCredit());
+ printf(SINF SWAL "depth is %d, blocks to maturity is %d and credit is %d\n",
+ wtx.GetDepthInMainChain(), wtx.GetBlocksToMaturity(), wtx.GetCredit());
}
}
- printf("\n");
}
bool CWallet::GetTransaction(const uint256 &hashTx, CWalletTx& wtx)
@@ -1267,7 +1270,7 @@
walletdb.WritePool(nIndex, CKeyPool(GenerateNewKey()));
setKeyPool.insert(nIndex);
}
- printf("CWallet::NewKeyPool wrote %"PRI64d" new keys\n", nKeys);
+ printf(SINF SWAL "%"PRI64d" new keys written\n", nKeys);
}
return true;
}
@@ -1291,7 +1294,7 @@
if (!walletdb.WritePool(nEnd, CKeyPool(GenerateNewKey())))
throw runtime_error("TopUpKeyPool() : writing generated key failed");
setKeyPool.insert(nEnd);
- printf("keypool added key %"PRI64d", size=%d\n", nEnd, setKeyPool.size());
+ printf(SINF SWAL "added key %"PRI64d", current size is %d\n", nEnd, setKeyPool.size());
}
}
return true;
@@ -1319,7 +1322,7 @@
if (!HaveKey(Hash160(keypool.vchPubKey)))
throw runtime_error("ReserveKeyFromKeyPool() : unknown key in key pool");
assert(!keypool.vchPubKey.empty());
- printf("keypool reserve %"PRI64d"\n", nIndex);
+ printf(SINF SWAL "keypool reserve %"PRI64d"\n", nIndex);
}
}
@@ -1331,7 +1334,7 @@
CWalletDB walletdb(strWalletFile);
walletdb.ErasePool(nIndex);
}
- printf("keypool keep %"PRI64d"\n", nIndex);
+ printf(SINF SWAL "keypool keep %"PRI64d"\n", nIndex);
}
void CWallet::ReturnKey(int64 nIndex)
@@ -1339,7 +1342,7 @@
// Return to key pool
CRITICAL_BLOCK(cs_wallet)
setKeyPool.insert(nIndex);
- printf("keypool return %"PRI64d"\n", nIndex);
+ printf(SINF SWAL "keypool return %"PRI64d"\n", nIndex);
}
bool CWallet::GetKeyFromPool(vector<unsigned char>& result, bool fAllowReuse)
@@ -1387,7 +1390,7 @@
vchPubKey = keypool.vchPubKey;
else
{
- printf("CReserveKey::GetReservedKey(): Warning: using default key instead of a new key, top up your keypool.");
+ printf(SWAR SWAL "using default key instead of a new key, top up your keypool\n");
vchPubKey = pwallet->vchDefaultKey;
}
}
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
iQIcBAABAgAGBQJWr1ibAAoJEBHMkEKSnTaCWHsQAJhCI5xipDi3nnrwcbaqJzxF
zJzMWjPUSlQ0+HEa9xnUd6xdU48qw+gaRYGnwZtyrKhA9EuJi6fWdpcLG0UtIpoq
4d5KCN1Cd+86RuPqH0hihmAGbqtrsUuIihKTtnt4tSZRABx4PXVMwU9aJ9naUfTs
bKcBX2JfaSTPio5g8Ib2yE/WguAs3qbLYGWWrQUQJa7SgUpP8lrzTer7jPQ9bwnL
bx8WhOdqeh7o4hzucm81E/SNg1TNM4ym81A+++E4V5cl112vwyjFAj1GuWe6DMw/
j4hphz8hqbq0MVd9scfT1es84Q5dk+vji9S9VnFUj4jCAXHlf31jvhDdmqFE5BOG
WD2Kvn24NgPaFzAdLm/Pd5N+yRvUUtAvRngWeNap6vqP/4uy3ixtDaYnuFYBHBlF
Qp522Pvo/5nHwkhDfvDjM6MCwr6+Hwu7KpF+0iMuhxqVI2SgtU0SvadG+K5X+FGy
iqdwwK3XVk48y+gVcAAgrwOyOaxONuqtaz2EICIMf44OjMNqgV9cuGGZSaALMlTG
lr6uezA3nuogQdfNMzr02sNhGGQiRsTHiEXJZYloGD7GgYdmudxh8/ZDEnmavtNb
1EHyO9X9fssVq6hFduOFLkI9hK/d62pgsgPPc8UtShVO4LBW1o3qLUePg/htrkyI
Www9wiakBPFKkuNLqryn
=Gon4
-----END PGP SIGNATURE-----
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment