diff --git a/src/activemasternode.cpp b/src/activemasternode.cpp index 6499a040de1389..832817e5cb3e2b 100644 --- a/src/activemasternode.cpp +++ b/src/activemasternode.cpp @@ -21,7 +21,7 @@ void CActiveMasternode::ManageStatus() if (!fMasterNode) return; - if (fDebug) LogPrintf("CActiveMasternode::ManageStatus() - Begin\n"); + if (logCategories != BCLog::NONE) LogPrintf("CActiveMasternode::ManageStatus() - Begin\n"); //need correct blocks to send ping if (!Params().IsRegTestNet() && !masternodeSync.IsBlockchainSynced()) { @@ -198,8 +198,8 @@ bool CActiveMasternode::SendMasternodePing(std::string& errorMessage) if (mnodeman.mapSeenMasternodeBroadcast.count(hash)) mnodeman.mapSeenMasternodeBroadcast[hash].lastPing = mnp; mnp.Relay(); - return true; + } else { // Seems like we are trying to send a ping while the Masternode is not registered in the network errorMessage = "Obfuscation Masternode List doesn't include our Masternode, shutting down Masternode pinging service! " + vin.ToString(); diff --git a/src/addrman.cpp b/src/addrman.cpp index c6da8c114dc7e7..8343e49679a8af 100644 --- a/src/addrman.cpp +++ b/src/addrman.cpp @@ -242,7 +242,7 @@ void CAddrMan::Good_(const CService& addr, int64_t nTime) if (nUBucket == -1) return; - LogPrint("addrman", "Moving %s to tried\n", addr.ToString()); + LogPrint(BCLog::ADDRMAN, "Moving %s to tried\n", addr.ToString()); // move nId to the tried tables MakeTried(info, nId); @@ -505,4 +505,4 @@ void CAddrMan::Connected_(const CService& addr, int64_t nTime) int CAddrMan::RandomInt(int nMax){ return GetRandInt(nMax); -} \ No newline at end of file +} diff --git a/src/addrman.h b/src/addrman.h index 74444e374e8889..13784fc7f38bd5 100644 --- a/src/addrman.h +++ b/src/addrman.h @@ -436,7 +436,7 @@ class CAddrMan } } if (nLost + nLostUnk > 0) { - LogPrint("addrman", "addrman lost %i new and %i tried addresses due to collisions\n", nLostUnk, nLost); + LogPrint(BCLog::ADDRMAN, "addrman lost %i new and %i tried addresses due to collisions\n", nLostUnk, nLost); } Check(); @@ -508,7 +508,7 @@ class CAddrMan Check(); } if (fRet) - LogPrint("addrman", "Added %s from %s: %i tried, %i new\n", addr.ToStringIPPort(), source.ToString(), nTried, nNew); + LogPrint(BCLog::ADDRMAN, "Added %s from %s: %i tried, %i new\n", addr.ToStringIPPort(), source.ToString(), nTried, nNew); return fRet; } @@ -524,7 +524,7 @@ class CAddrMan Check(); } if (nAdd) - LogPrint("addrman", "Added %i addresses from %s: %i tried, %i new\n", nAdd, source.ToString(), nTried, nNew); + LogPrint(BCLog::ADDRMAN, "Added %i addresses from %s: %i tried, %i new\n", nAdd, source.ToString(), nTried, nNew); return nAdd > 0; } diff --git a/src/consensus/zerocoin_verify.cpp b/src/consensus/zerocoin_verify.cpp index 430905cf5fc42f..c7c69e0bc13a0d 100644 --- a/src/consensus/zerocoin_verify.cpp +++ b/src/consensus/zerocoin_verify.cpp @@ -361,7 +361,7 @@ bool UpdateZPIVSupply(const CBlock& block, CBlockIndex* pindex, bool fJustCheck) } for (const auto& denom : libzerocoin::zerocoinDenomList) - LogPrint("zero", "%s coins for denomination %d pubcoin %s\n", __func__, denom, pindex->mapZerocoinSupply.at(denom)); + LogPrint(BCLog::LEGACYZC, "%s coins for denomination %d pubcoin %s\n", __func__, denom, pindex->mapZerocoinSupply.at(denom)); return true; } diff --git a/src/denomination_functions.cpp b/src/denomination_functions.cpp index 5db1feb6e3ce1e..820bb1206586cf 100644 --- a/src/denomination_functions.cpp +++ b/src/denomination_functions.cpp @@ -155,10 +155,10 @@ void listSpends(const std::vector& vSelectedMints) CAmount nTotal = 0; for (auto& denom : libzerocoin::zerocoinDenomList) { - LogPrint("zero", "%s %d coins for denomination %d used\n", __func__, mapZerocoinSupply.at(denom), denom); + LogPrint(BCLog::LEGACYZC, "%s %d coins for denomination %d used\n", __func__, mapZerocoinSupply.at(denom), denom); nTotal += libzerocoin::ZerocoinDenominationToAmount(denom); } - LogPrint("zero", "Total value of coins %d\n", nTotal); + LogPrint(BCLog::LEGACYZC, "Total value of coins %d\n", nTotal); } // ------------------------------------------------------------------------------------------------------- @@ -416,11 +416,11 @@ std::vector SelectMintsFromList(const CAmount nValueTarget, CAmount& // calculate the change needed and the map of coins used nCoinsReturned = calculateChange(nMaxNumberOfSpends, nValueTarget, mapOfDenomsHeld, mapOfDenomsUsed); if (nCoinsReturned == 0) { - LogPrint("zero", "%s: Problem getting change (TBD) or Too many spends %d\n", __func__, nValueTarget); + LogPrint(BCLog::LEGACYZC, "%s: Problem getting change (TBD) or Too many spends %d\n", __func__, nValueTarget); vSelectedMints.clear(); } else { vSelectedMints = getSpends(listMints, mapOfDenomsUsed, nSelectedValue); - LogPrint("zero", "%s: %d coins in change for %d\n", __func__, nCoinsReturned, nValueTarget); + LogPrint(BCLog::LEGACYZC, "%s: %d coins in change for %d\n", __func__, nCoinsReturned, nValueTarget); } return vSelectedMints; } diff --git a/src/httprpc.cpp b/src/httprpc.cpp index 7cc106f2c456e0..425ac02bd2d6ad 100644 --- a/src/httprpc.cpp +++ b/src/httprpc.cpp @@ -169,7 +169,7 @@ static bool InitRPCAuthentication() bool StartHTTPRPC() { - LogPrint("rpc", "Starting HTTP RPC server\n"); + LogPrint(BCLog::RPC, "Starting HTTP RPC server\n"); if (!InitRPCAuthentication()) return false; @@ -183,12 +183,12 @@ bool StartHTTPRPC() void InterruptHTTPRPC() { - LogPrint("rpc", "Interrupting HTTP RPC server\n"); + LogPrint(BCLog::RPC, "Interrupting HTTP RPC server\n"); } void StopHTTPRPC() { - LogPrint("rpc", "Stopping HTTP RPC server\n"); + LogPrint(BCLog::RPC, "Stopping HTTP RPC server\n"); UnregisterHTTPHandler("/", true); if (httpRPCTimerInterface) { RPCUnsetTimerInterface(httpRPCTimerInterface); diff --git a/src/httpserver.cpp b/src/httpserver.cpp index c6690ab23cfe76..2eec32ca90365e 100644 --- a/src/httpserver.cpp +++ b/src/httpserver.cpp @@ -221,7 +221,7 @@ static bool InitHTTPAllowList() std::string strAllowed; for (const CSubNet& subnet : rpc_allow_subnets) strAllowed += subnet.ToString() + " "; - LogPrint("http", "Allowing HTTP connections from: %s\n", strAllowed); + LogPrint(BCLog::HTTP, "Allowing HTTP connections from: %s\n", strAllowed); return true; } @@ -251,7 +251,7 @@ static void http_request_cb(struct evhttp_request* req, void* arg) { std::unique_ptr hreq(new HTTPRequest(req)); - LogPrint("http", "Received a %s request for %s from %s\n", + LogPrint(BCLog::HTTP, "Received a %s request for %s from %s\n", RequestMethodString(hreq->GetRequestMethod()), hreq->GetURI(), hreq->GetPeer().ToString()); // Early address-based allow check @@ -299,17 +299,17 @@ static void http_request_cb(struct evhttp_request* req, void* arg) /** Callback to reject HTTP requests after shutdown. */ static void http_reject_request_cb(struct evhttp_request* req, void*) { - LogPrint("http", "Rejecting request while shutting down\n"); + LogPrint(BCLog::HTTP, "Rejecting request while shutting down\n"); evhttp_send_error(req, HTTP_SERVUNAVAIL, NULL); } /** Event dispatcher thread */ static bool ThreadHTTP(struct event_base* base, struct evhttp* http) { util::ThreadRename("bitcoin-http"); - LogPrint("http", "Entering http event loop\n"); + LogPrint(BCLog::HTTP, "Entering http event loop\n"); event_base_dispatch(base); // Event loop will be interrupted by InterruptHTTPServer() - LogPrint("http", "Exited http event loop\n"); + LogPrint(BCLog::HTTP, "Exited http event loop\n"); return event_base_got_break(base) == 0; } @@ -341,7 +341,7 @@ static bool HTTPBindAddresses(struct evhttp* http) // Bind addresses for (std::vector >::iterator i = endpoints.begin(); i != endpoints.end(); ++i) { - LogPrint("http", "Binding RPC on address %s port %i\n", i->first, i->second); + LogPrint(BCLog::HTTP, "Binding RPC on address %s port %i\n", i->first, i->second); evhttp_bound_socket *bind_handle = evhttp_bind_socket_with_handle(http, i->first.empty() ? NULL : i->first.c_str(), i->second); if (bind_handle) { boundSockets.push_back(bind_handle); @@ -369,7 +369,7 @@ static void libevent_log_cb(int severity, const char *msg) if (severity >= EVENT_LOG_WARN) // Log warn messages and higher without debug category LogPrintf("libevent: %s\n", msg); else - LogPrint("libevent", "libevent: %s\n", msg); + LogPrint(BCLog::LIBEVENT, "libevent: %s\n", msg); } bool InitHTTPServer() @@ -392,7 +392,7 @@ bool InitHTTPServer() #if LIBEVENT_VERSION_NUMBER >= 0x02010100 // If -debug=libevent, set full libevent debugging. // Otherwise, disable all libevent debugging. - if (LogAcceptCategory("libevent")) + if (LogAcceptCategory(BCLog::LIBEVENT)) event_enable_debug_logging(EVENT_DBG_ALL); else event_enable_debug_logging(EVENT_DBG_NONE); @@ -429,7 +429,7 @@ bool InitHTTPServer() return false; } - LogPrint("http", "Initialized HTTP server\n"); + LogPrint(BCLog::HTTP, "Initialized HTTP server\n"); int workQueueDepth = std::max((long)GetArg("-rpcworkqueue", DEFAULT_HTTP_WORKQUEUE), 1L); LogPrintf("HTTP: creating work queue of depth %d\n", workQueueDepth); @@ -444,7 +444,7 @@ std::future threadResult; bool StartHTTPServer() { - LogPrint("http", "Starting HTTP server\n"); + LogPrint(BCLog::HTTP, "Starting HTTP server\n"); int rpcThreads = std::max((long)GetArg("-rpcthreads", DEFAULT_HTTP_THREADS), 1L); LogPrintf("HTTP: starting %d worker threads\n", rpcThreads); std::packaged_task task(ThreadHTTP); @@ -460,7 +460,7 @@ bool StartHTTPServer() void InterruptHTTPServer() { - LogPrint("http", "Interrupting HTTP server\n"); + LogPrint(BCLog::HTTP, "Interrupting HTTP server\n"); if (eventHTTP) { for (evhttp_bound_socket *socket : boundSockets) { evhttp_del_accept_socket(eventHTTP, socket); @@ -473,15 +473,15 @@ void InterruptHTTPServer() void StopHTTPServer() { - LogPrint("http", "Stopping HTTP server\n"); + LogPrint(BCLog::HTTP, "Stopping HTTP server\n"); if (workQueue) { - LogPrint("http", "Waiting for HTTP worker threads to exit\n"); + LogPrint(BCLog::HTTP, "Waiting for HTTP worker threads to exit\n"); workQueue->WaitExit(); delete workQueue; } MilliSleep(500); // Avoid race condition while the last HTTP-thread is exiting if (eventBase) { - LogPrint("http", "Waiting for HTTP event thread to exit\n"); + LogPrint(BCLog::HTTP, "Waiting for HTTP event thread to exit\n"); // Give event loop a few seconds to exit (to send back last RPC responses), then break it // Before this was solved with event_base_loopexit, but that didn't work as expected in // at least libevent 2.0.21 and always introduced a delay. In libevent @@ -503,7 +503,7 @@ void StopHTTPServer() event_base_free(eventBase); eventBase = 0; } - LogPrint("http", "Stopped HTTP server\n"); + LogPrint(BCLog::HTTP, "Stopped HTTP server\n"); } struct event_base* EventBase() @@ -650,7 +650,7 @@ HTTPRequest::RequestMethod HTTPRequest::GetRequestMethod() void RegisterHTTPHandler(const std::string &prefix, bool exactMatch, const HTTPRequestHandler &handler) { - LogPrint("http", "Registering HTTP handler for %s (exactmatch %d)\n", prefix, exactMatch); + LogPrint(BCLog::HTTP, "Registering HTTP handler for %s (exactmatch %d)\n", prefix, exactMatch); pathHandlers.push_back(HTTPPathHandler(prefix, exactMatch, handler)); } @@ -663,7 +663,7 @@ void UnregisterHTTPHandler(const std::string &prefix, bool exactMatch) break; if (i != iend) { - LogPrint("http", "Unregistering HTTP handler for %s (exactmatch %d)\n", prefix, exactMatch); + LogPrint(BCLog::HTTP, "Unregistering HTTP handler for %s (exactmatch %d)\n", prefix, exactMatch); pathHandlers.erase(i); } } diff --git a/src/init.cpp b/src/init.cpp index 68c4e36dfcf566..357999b1c8088d 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -360,7 +360,7 @@ void OnRPCStopped() uiInterface.NotifyBlockTip.disconnect(RPCNotifyBlockChange); //RPCNotifyBlockChange(0); g_best_block_cv.notify_all(); - LogPrint("rpc", "RPC stopped.\n"); + LogPrint(BCLog::RPC, "RPC stopped.\n"); } void OnRPCPreCommand(const CRPCCommand& cmd) @@ -506,11 +506,8 @@ std::string HelpMessage(HelpMessageMode mode) strUsage += HelpMessageOpt("-stopafterblockimport", strprintf(_("Stop running after importing blocks from disk (default: %u)"), 0)); strUsage += HelpMessageOpt("-sporkkey=", _("Enable spork administration functionality with the appropriate private key.")); } - std::string debugCategories = "addrman, alert, bench, coindb, db, lock, rand, rpc, selectcoins, tor, mempool, net, proxy, http, libevent, pivx, (obfuscation, swiftx, masternode, mnpayments, mnbudget, zero, staking)"; // Don't translate these and qt below - if (mode == HMM_BITCOIN_QT) - debugCategories += ", qt"; strUsage += HelpMessageOpt("-debug=", strprintf(_("Output debugging information (default: %u, supplying is optional)"), 0) + ". " + - _("If is not supplied, output all debugging information.") + _(" can be:") + " " + debugCategories + "."); + _("If is not supplied, output all debugging information.") + _(" can be:") + " " + ListLogCategories() + "."); if (GetBoolArg("-help-debug", false)) strUsage += HelpMessageOpt("-nodebug", "Turn off debugging messages, same as -debug=0"); #ifdef ENABLE_WALLET @@ -949,11 +946,19 @@ bool AppInit2() // ********************************************************* Step 3: parameter-to-internal-flags - fDebug = !mapMultiArgs["-debug"].empty(); // Special-case: if -debug=0/-nodebug is set, turn off debugging messages const std::vector& categories = mapMultiArgs["-debug"]; - if (GetBoolArg("-nodebug", false) || find(categories.begin(), categories.end(), std::string("0")) != categories.end()) - fDebug = false; + + if (!(GetBoolArg("-nodebug", false) || + find(categories.begin(), categories.end(), std::string("0")) != categories.end())) { + for (const auto& cat : categories) { + uint32_t flag; + if (!GetLogCategory(&flag, &cat)) { + InitWarning(strprintf(_("Unsupported logging category %s.\n"), cat)); + } + logCategories |= flag; + } + } // Check for -debugnet if (GetBoolArg("-debugnet", false)) @@ -1094,7 +1099,7 @@ bool AppInit2() #ifndef WIN32 CreatePidFile(GetPidFile(), getpid()); #endif - if (GetBoolArg("-shrinkdebugfile", !fDebug)) + if (GetBoolArg("-shrinkdebugfile", logCategories != BCLog::NONE)) ShrinkDebugFile(); LogPrintf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); LogPrintf("PIVX version %s (%s)\n", FormatFullVersion(), CLIENT_DATE); @@ -1588,7 +1593,7 @@ bool AppInit2() } } } catch (const std::exception& e) { - if (fDebug) LogPrintf("%s\n", e.what()); + LogPrintf("%s\n", e.what()); strLoadError = _("Error opening block database"); fVerifyingBlocks = false; break; diff --git a/src/kernel.cpp b/src/kernel.cpp index 7a0977596a0d65..06837062e41266 100644 --- a/src/kernel.cpp +++ b/src/kernel.cpp @@ -69,7 +69,7 @@ bool CStakeKernel::CheckKernelHash(bool fSkipLog) const const bool res = hashProofOfStake < bnTarget; if (!fSkipLog || res) { - LogPrint("staking", "%s : Proof Of Stake:" + LogPrint(BCLog::STAKING, "%s : Proof Of Stake:" "\nssUniqueID=%s" "\nnTimeTx=%d" "\nhashProofOfStake=%s" diff --git a/src/main.cpp b/src/main.cpp index 4a3414d7d8824a..c1d9f4b69a47a7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -647,7 +647,7 @@ bool AddOrphanTx(const CTransaction& tx, NodeId peer) // at most 500 megabytes of orphans: unsigned int sz = tx.GetSerializeSize(SER_NETWORK, CTransaction::CURRENT_VERSION); if (sz > 5000) { - LogPrint("mempool", "ignoring large orphan tx (size: %u, hash: %s)\n", sz, hash.ToString()); + LogPrint(BCLog::MEMPOOL, "ignoring large orphan tx (size: %u, hash: %s)\n", sz, hash.ToString()); return false; } @@ -656,7 +656,7 @@ bool AddOrphanTx(const CTransaction& tx, NodeId peer) for (const CTxIn& txin : tx.vin) mapOrphanTransactionsByPrev[txin.prevout.hash].insert(hash); - LogPrint("mempool", "stored orphan tx %s (mapsz %u prevsz %u)\n", hash.ToString(), + LogPrint(BCLog::MEMPOOL, "stored orphan tx %s (mapsz %u prevsz %u)\n", hash.ToString(), mapOrphanTransactions.size(), mapOrphanTransactionsByPrev.size()); return true; } @@ -688,7 +688,7 @@ void EraseOrphansFor(NodeId peer) ++nErased; } } - if (nErased > 0) LogPrint("mempool", "Erased %d orphan tx from peer %d\n", nErased, peer); + if (nErased > 0) LogPrint(BCLog::MEMPOOL, "Erased %d orphan tx from peer %d\n", nErased, peer); } @@ -1169,7 +1169,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState& state, const CTransa if (dFreeCount >= GetArg("-limitfreerelay", 30) * 10 * 1000) return state.DoS(0, error("%s : free transaction rejected by rate limiter", __func__), REJECT_INSUFFICIENTFEE, "rate limited free transaction"); - LogPrint("mempool", "Rate limit dFreeCount: %g => %g\n", dFreeCount, dFreeCount + nSize); + LogPrint(BCLog::MEMPOOL, "Rate limit dFreeCount: %g => %g\n", dFreeCount, dFreeCount + nSize); dFreeCount += nSize; } } @@ -1369,7 +1369,7 @@ bool AcceptableInputs(CTxMemPool& pool, CValidationState& state, const CTransact if (dFreeCount >= GetArg("-limitfreerelay", 30) * 10 * 1000) return state.DoS(0, error("AcceptableInputs : free transaction rejected by rate limiter"), REJECT_INSUFFICIENTFEE, "rate limited free transaction"); - LogPrint("mempool", "Rate limit dFreeCount: %g => %g\n", dFreeCount, dFreeCount + nSize); + LogPrint(BCLog::MEMPOOL, "Rate limit dFreeCount: %g => %g\n", dFreeCount, dFreeCount + nSize); dFreeCount += nSize; } } @@ -1638,7 +1638,7 @@ CAmount GetSeeSaw(const CAmount& blockValue, int nMasternodeCount, int nHeight) int64_t nMoneySupply = chainActive.Tip()->nMoneySupply; int64_t mNodeCoins = nMasternodeCount * 10000 * COIN; - if (fDebug) + if (logCategories != BCLog::NONE) LogPrintf("GetMasternodePayment(): moneysupply=%s, nodecoins=%s \n", FormatMoney(nMoneySupply).c_str(), FormatMoney(mNodeCoins).c_str()); @@ -2686,7 +2686,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin int64_t nTime1 = GetTimeMicros(); nTimeConnect += nTime1 - nTimeStart; - LogPrint("bench", " - Connect %u transactions: %.2fms (%.3fms/tx, %.3fms/txin) [%.2fs]\n", (unsigned)block.vtx.size(), 0.001 * (nTime1 - nTimeStart), 0.001 * (nTime1 - nTimeStart) / block.vtx.size(), nInputs <= 1 ? 0 : 0.001 * (nTime1 - nTimeStart) / (nInputs - 1), nTimeConnect * 0.000001); + LogPrint(BCLog::BENCH, " - Connect %u transactions: %.2fms (%.3fms/tx, %.3fms/txin) [%.2fs]\n", (unsigned)block.vtx.size(), 0.001 * (nTime1 - nTimeStart), 0.001 * (nTime1 - nTimeStart) / block.vtx.size(), nInputs <= 1 ? 0 : 0.001 * (nTime1 - nTimeStart) / (nInputs - 1), nTimeConnect * 0.000001); //PoW phase redistributed fees to miner. PoS stage destroys fees. CAmount nExpectedMint = GetBlockValue(pindex->pprev->nHeight); @@ -2704,7 +2704,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin return state.DoS(100, error("%s: CheckQueue failed", __func__), REJECT_INVALID, "block-validation-failed"); int64_t nTime2 = GetTimeMicros(); nTimeVerify += nTime2 - nTimeStart; - LogPrint("bench", " - Verify %u txins: %.2fms (%.3fms/txin) [%.2fs]\n", nInputs - 1, 0.001 * (nTime2 - nTimeStart), nInputs <= 1 ? 0 : 0.001 * (nTime2 - nTimeStart) / (nInputs - 1), nTimeVerify * 0.000001); + LogPrint(BCLog::BENCH, " - Verify %u txins: %.2fms (%.3fms/txin) [%.2fs]\n", nInputs - 1, 0.001 * (nTime2 - nTimeStart), nInputs <= 1 ? 0 : 0.001 * (nTime2 - nTimeStart) / (nInputs - 1), nTimeVerify * 0.000001); //IMPORTANT NOTE: Nothing before this point should actually store to disk (or even memory) if (fJustCheck) @@ -2773,7 +2773,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin int64_t nTime3 = GetTimeMicros(); nTimeIndex += nTime3 - nTime2; - LogPrint("bench", " - Index writing: %.2fms [%.2fs]\n", 0.001 * (nTime3 - nTime2), nTimeIndex * 0.000001); + LogPrint(BCLog::BENCH, " - Index writing: %.2fms [%.2fs]\n", 0.001 * (nTime3 - nTime2), nTimeIndex * 0.000001); // Watch for changes to the previous coinbase transaction. static uint256 hashPrevBestCoinBase; @@ -2782,7 +2782,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin int64_t nTime4 = GetTimeMicros(); nTimeCallbacks += nTime4 - nTime3; - LogPrint("bench", " - Callbacks: %.2fms [%.2fs]\n", 0.001 * (nTime4 - nTime3), nTimeCallbacks * 0.000001); + LogPrint(BCLog::BENCH, " - Callbacks: %.2fms [%.2fs]\n", 0.001 * (nTime4 - nTime3), nTimeCallbacks * 0.000001); //Continue tracking possible movement of fraudulent funds until they are completely frozen if (pindex->nHeight >= consensus.height_start_ZC_InvalidSerials && @@ -2927,7 +2927,7 @@ bool static DisconnectTip(CValidationState& state) return error("DisconnectTip() : DisconnectBlock %s failed", pindexDelete->GetBlockHash().ToString()); assert(view.Flush()); } - LogPrint("bench", "- Disconnect block: %.2fms\n", (GetTimeMicros() - nStart) * 0.001); + LogPrint(BCLog::BENCH, "- Disconnect block: %.2fms\n", (GetTimeMicros() - nStart) * 0.001); // Write the chain state to disk, if necessary. if (!FlushStateToDisk(state, FLUSH_STATE_ALWAYS)) return false; @@ -2982,7 +2982,7 @@ bool static ConnectTip(CValidationState& state, CBlockIndex* pindexNew, CBlock* int64_t nTime2 = GetTimeMicros(); nTimeReadFromDisk += nTime2 - nTime1; int64_t nTime3; - LogPrint("bench", " - Load block from disk: %.2fms [%.2fs]\n", (nTime2 - nTime1) * 0.001, nTimeReadFromDisk * 0.000001); + LogPrint(BCLog::BENCH, " - Load block from disk: %.2fms [%.2fs]\n", (nTime2 - nTime1) * 0.001, nTimeReadFromDisk * 0.000001); { CInv inv(MSG_BLOCK, pindexNew->GetBlockHash()); bool rv = ConnectBlock(*pblock, state, pindexNew, view, false, fAlreadyChecked); @@ -2995,12 +2995,12 @@ bool static ConnectTip(CValidationState& state, CBlockIndex* pindexNew, CBlock* mapBlockSource.erase(inv.hash); nTime3 = GetTimeMicros(); nTimeConnectTotal += nTime3 - nTime2; - LogPrint("bench", " - Connect total: %.2fms [%.2fs]\n", (nTime3 - nTime2) * 0.001, nTimeConnectTotal * 0.000001); + LogPrint(BCLog::BENCH, " - Connect total: %.2fms [%.2fs]\n", (nTime3 - nTime2) * 0.001, nTimeConnectTotal * 0.000001); assert(view.Flush()); } int64_t nTime4 = GetTimeMicros(); nTimeFlush += nTime4 - nTime3; - LogPrint("bench", " - Flush: %.2fms [%.2fs]\n", (nTime4 - nTime3) * 0.001, nTimeFlush * 0.000001); + LogPrint(BCLog::BENCH, " - Flush: %.2fms [%.2fs]\n", (nTime4 - nTime3) * 0.001, nTimeFlush * 0.000001); // Write the chain state to disk, if necessary. Always write to disk if this is the first of a new file. FlushStateMode flushMode = FLUSH_STATE_IF_NEEDED; @@ -3010,7 +3010,7 @@ bool static ConnectTip(CValidationState& state, CBlockIndex* pindexNew, CBlock* return false; int64_t nTime5 = GetTimeMicros(); nTimeChainState += nTime5 - nTime4; - LogPrint("bench", " - Writing chainstate: %.2fms [%.2fs]\n", (nTime5 - nTime4) * 0.001, nTimeChainState * 0.000001); + LogPrint(BCLog::BENCH, " - Writing chainstate: %.2fms [%.2fs]\n", (nTime5 - nTime4) * 0.001, nTimeChainState * 0.000001); // Remove conflicting transactions from the mempool. std::list txConflicted; @@ -3031,8 +3031,8 @@ bool static ConnectTip(CValidationState& state, CBlockIndex* pindexNew, CBlock* int64_t nTime6 = GetTimeMicros(); nTimePostConnect += nTime6 - nTime5; nTimeTotal += nTime6 - nTime1; - LogPrint("bench", " - Connect postprocess: %.2fms [%.2fs]\n", (nTime6 - nTime5) * 0.001, nTimePostConnect * 0.000001); - LogPrint("bench", "- Connect block: %.2fms [%.2fs]\n", (nTime6 - nTime1) * 0.001, nTimeTotal * 0.000001); + LogPrint(BCLog::BENCH, " - Connect postprocess: %.2fms [%.2fs]\n", (nTime6 - nTime5) * 0.001, nTimePostConnect * 0.000001); + LogPrint(BCLog::BENCH, "- Connect block: %.2fms [%.2fs]\n", (nTime6 - nTime1) * 0.001, nTimeTotal * 0.000001); return true; } @@ -3697,14 +3697,12 @@ bool CheckColdStakeFreeOutput(const CTransaction& tx, const int nHeight) bool CheckBlock(const CBlock& block, CValidationState& state, bool fCheckPOW, bool fCheckMerkleRoot, bool fCheckSig) { - // These are checks that are independent of context. - const bool IsPoS = block.IsProofOfStake(); - LogPrint("debug", "%s: block=%s is proof of stake=%d\n", __func__, block.GetHash().ToString().c_str(), IsPoS); - - if (block.fChecked) return true; + // These are checks that are independent of context. + const bool IsPoS = block.IsProofOfStake(); + // Check that the header is valid (particularly PoW). This is mostly // redundant with the call in AcceptBlockHeader. if (!CheckBlockHeader(block, state, !IsPoS)) @@ -3822,7 +3820,7 @@ bool CheckBlock(const CBlock& block, CValidationState& state, bool fCheckPOW, bo REJECT_INVALID, "bad-cb-payee"); } } else { - if (fDebug) + if (logCategories != BCLog::NONE) LogPrintf("%s: Masternode/Budget payment checks skipped on sync\n", __func__); } } @@ -4923,8 +4921,8 @@ bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos* dbp) // detect out of order blocks, and store them for later uint256 hash = block.GetHash(); if (hash != Params().GetConsensus().hashGenesisBlock && mapBlockIndex.find(block.hashPrevBlock) == mapBlockIndex.end()) { - LogPrint("reindex", "%s: Out of order block %s, parent %s not known\n", __func__, hash.ToString(), - block.hashPrevBlock.ToString()); + LogPrint(BCLog::REINDEX, "%s: Out of order block %s, parent %s not known\n", __func__, + hash.GetHex(), block.hashPrevBlock.GetHex()); if (dbp) mapBlocksUnknownParent.insert(std::make_pair(block.hashPrevBlock, *dbp)); continue; @@ -5456,7 +5454,7 @@ void static ProcessGetData(CNode* pfrom) bool fRequestedSporksIDB = false; bool static ProcessMessage(CNode* pfrom, std::string strCommand, CDataStream& vRecv, int64_t nTimeReceived) { - LogPrint("net", "received: %s (%u bytes) peer=%d\n", SanitizeString(strCommand), vRecv.size(), pfrom->id); + LogPrint(BCLog::NET, "received: %s (%u bytes) peer=%d\n", SanitizeString(strCommand), vRecv.size(), pfrom->id); if (mapArgs.count("-dropmessagestest") && GetRand(atoi(mapArgs["-dropmessagestest"])) == 0) { LogPrintf("dropmessagestest DROPPING RECV MESSAGE\n"); return true; @@ -5689,7 +5687,7 @@ bool static ProcessMessage(CNode* pfrom, std::string strCommand, CDataStream& vR pfrom->AddInventoryKnown(inv); bool fAlreadyHave = AlreadyHave(inv); - LogPrint("net", "got inv: %s %s peer=%d\n", inv.ToString(), fAlreadyHave ? "have" : "new", pfrom->id); + LogPrint(BCLog::NET, "got inv: %s %s peer=%d\n", inv.ToString(), fAlreadyHave ? "have" : "new", pfrom->id); if (!fAlreadyHave && !fImporting && !fReindex && inv.type != MSG_BLOCK) pfrom->AskFor(inv); @@ -5700,7 +5698,7 @@ bool static ProcessMessage(CNode* pfrom, std::string strCommand, CDataStream& vR if (!fAlreadyHave && !fImporting && !fReindex && !mapBlocksInFlight.count(inv.hash)) { // Add this to the list of blocks to request vToFetch.push_back(inv); - LogPrint("net", "getblocks (%d) %s to peer=%d\n", pindexBestHeader->nHeight, inv.hash.ToString(), pfrom->id); + LogPrint(BCLog::NET, "getblocks (%d) %s to peer=%d\n", pindexBestHeader->nHeight, inv.hash.ToString(), pfrom->id); } } @@ -5727,11 +5725,11 @@ bool static ProcessMessage(CNode* pfrom, std::string strCommand, CDataStream& vR return error("message getdata size() = %u", vInv.size()); } - if (fDebug || (vInv.size() != 1)) - LogPrint("net", "received getdata (%u invsz) peer=%d\n", vInv.size(), pfrom->id); + if (vInv.size() != 1) + LogPrint(BCLog::NET, "received getdata (%u invsz) peer=%d\n", vInv.size(), pfrom->id); - if ((fDebug && vInv.size() > 0) || (vInv.size() == 1)) - LogPrint("net", "received getdata for: %s peer=%d\n", vInv[0].ToString(), pfrom->id); + if (vInv.size() > 0) + LogPrint(BCLog::NET, "received getdata for: %s peer=%d\n", vInv[0].ToString(), pfrom->id); pfrom->vRecvGetData.insert(pfrom->vRecvGetData.end(), vInv.begin(), vInv.end()); ProcessGetData(pfrom); @@ -5744,7 +5742,7 @@ bool static ProcessMessage(CNode* pfrom, std::string strCommand, CDataStream& vR vRecv >> locator >> hashStop; if (locator.vHave.size() > MAX_LOCATOR_SZ) { - LogPrint("net", "getblocks locator size %lld > %d, disconnect peer=%d\n", locator.vHave.size(), MAX_LOCATOR_SZ, pfrom->GetId()); + LogPrint(BCLog::NET, "getblocks locator size %lld > %d, disconnect peer=%d\n", locator.vHave.size(), MAX_LOCATOR_SZ, pfrom->GetId()); pfrom->fDisconnect = true; return true; } @@ -5758,17 +5756,17 @@ bool static ProcessMessage(CNode* pfrom, std::string strCommand, CDataStream& vR if (pindex) pindex = chainActive.Next(pindex); int nLimit = 500; - LogPrint("net", "getblocks %d to %s limit %d from peer=%d\n", (pindex ? pindex->nHeight : -1), hashStop.IsNull() ? "end" : hashStop.ToString(), nLimit, pfrom->id); + LogPrint(BCLog::NET, "getblocks %d to %s limit %d from peer=%d\n", (pindex ? pindex->nHeight : -1), hashStop.IsNull() ? "end" : hashStop.ToString(), nLimit, pfrom->id); for (; pindex; pindex = chainActive.Next(pindex)) { if (pindex->GetBlockHash() == hashStop) { - LogPrint("net", " getblocks stopping at %d %s\n", pindex->nHeight, pindex->GetBlockHash().ToString()); + LogPrint(BCLog::NET, " getblocks stopping at %d %s\n", pindex->nHeight, pindex->GetBlockHash().ToString()); break; } pfrom->PushInventory(CInv(MSG_BLOCK, pindex->GetBlockHash())); if (--nLimit <= 0) { // When this block is requested, we'll send an inv that'll make them // getblocks the next batch of inventory. - LogPrint("net", " getblocks stopping at limit %d %s\n", pindex->nHeight, pindex->GetBlockHash().ToString()); + LogPrint(BCLog::NET, " getblocks stopping at limit %d %s\n", pindex->nHeight, pindex->GetBlockHash().ToString()); pfrom->hashContinue = pindex->GetBlockHash(); break; } @@ -5782,7 +5780,7 @@ bool static ProcessMessage(CNode* pfrom, std::string strCommand, CDataStream& vR vRecv >> locator >> hashStop; if (locator.vHave.size() > MAX_LOCATOR_SZ) { - LogPrint("net", "getblocks locator size %lld > %d, disconnect peer=%d\n", locator.vHave.size(), MAX_LOCATOR_SZ, pfrom->GetId()); + LogPrint(BCLog::NET, "getblocks locator size %lld > %d, disconnect peer=%d\n", locator.vHave.size(), MAX_LOCATOR_SZ, pfrom->GetId()); pfrom->fDisconnect = true; return true; } @@ -5809,7 +5807,7 @@ bool static ProcessMessage(CNode* pfrom, std::string strCommand, CDataStream& vR // we must use CBlocks, as CBlockHeaders won't include the 0x00 nTx count at the end std::vector vHeaders; int nLimit = MAX_HEADERS_RESULTS; - if (fDebug) + if (logCategories != BCLog::NONE) LogPrintf("getheaders %d to %s from peer=%d\n", (pindex ? pindex->nHeight : -1), hashStop.ToString(), pfrom->id); for (; pindex; pindex = chainActive.Next(pindex)) { vHeaders.push_back(pindex->GetBlockHeader()); @@ -5841,7 +5839,7 @@ bool static ProcessMessage(CNode* pfrom, std::string strCommand, CDataStream& vR if (pmn != NULL) { if (!pmn->allowFreeTx) { //multiple peers can send us a valid masternode transaction - if (fDebug) LogPrintf("dstx: Masternode sending too many transactions %s\n", tx.GetHash().ToString()); + LogPrint(BCLog::MASTERNODE, "Masternode sending too many transactions %s\n", tx.GetHash().ToString()); return true; } @@ -5852,7 +5850,7 @@ bool static ProcessMessage(CNode* pfrom, std::string strCommand, CDataStream& vR return error("dstx: Got bad masternode address signature %s, error: %s", vin.ToString(), errorMessage); } - LogPrintf("dstx: Got Masternode transaction %s\n", tx.GetHash().ToString()); + LogPrint(BCLog::MASTERNODE, "Got Masternode transaction %s\n", tx.GetHash().ToString()); ignoreFees = true; pmn->allowFreeTx = false; @@ -5885,7 +5883,7 @@ bool static ProcessMessage(CNode* pfrom, std::string strCommand, CDataStream& vR RelayTransaction(tx); vWorkQueue.push_back(inv.hash); - LogPrint("mempool", "AcceptToMemoryPool: peer=%d %s : accepted %s (poolsz %u)\n", + LogPrint(BCLog::MEMPOOL, "AcceptToMemoryPool: peer=%d %s : accepted %s (poolsz %u)\n", pfrom->id, pfrom->cleanSubVer, tx.GetHash().ToString(), mempool.mapTx.size()); @@ -5912,7 +5910,7 @@ bool static ProcessMessage(CNode* pfrom, std::string strCommand, CDataStream& vR if(setMisbehaving.count(fromPeer)) continue; if(AcceptToMemoryPool(mempool, stateDummy, orphanTx, true, &fMissingInputs2)) { - LogPrint("mempool", " accepted orphan tx %s\n", orphanHash.ToString()); + LogPrint(BCLog::MEMPOOL, " accepted orphan tx %s\n", orphanHash.ToString()); RelayTransaction(orphanTx); vWorkQueue.push_back(orphanHash); vEraseQueue.push_back(orphanHash); @@ -5922,11 +5920,11 @@ bool static ProcessMessage(CNode* pfrom, std::string strCommand, CDataStream& vR // Punish peer that gave us an invalid orphan tx Misbehaving(fromPeer, nDos); setMisbehaving.insert(fromPeer); - LogPrint("mempool", " invalid orphan tx %s\n", orphanHash.ToString()); + LogPrint(BCLog::MEMPOOL, " invalid orphan tx %s\n", orphanHash.ToString()); } // Has inputs but not accepted to mempool // Probably non-standard or insufficient fee/priority - LogPrint("mempool", " removed orphan tx %s\n", orphanHash.ToString()); + LogPrint(BCLog::MEMPOOL, " removed orphan tx %s\n", orphanHash.ToString()); vEraseQueue.push_back(orphanHash); } mempool.check(pcoinsTip); @@ -5939,7 +5937,7 @@ bool static ProcessMessage(CNode* pfrom, std::string strCommand, CDataStream& vR //Presstab: ZCoin has a bunch of code commented out here. Is this something that should have more going on? //Also there is nothing that handles fMissingZerocoinInputs. Does there need to be? RelayTransaction(tx); - LogPrint("mempool", "AcceptToMemoryPool: Zerocoinspend peer=%d %s : accepted %s (poolsz %u)\n", + LogPrint(BCLog::MEMPOOL, "AcceptToMemoryPool: Zerocoinspend peer=%d %s : accepted %s (poolsz %u)\n", pfrom->id, pfrom->cleanSubVer, tx.GetHash().ToString(), mempool.mapTx.size()); @@ -5950,7 +5948,7 @@ bool static ProcessMessage(CNode* pfrom, std::string strCommand, CDataStream& vR unsigned int nMaxOrphanTx = (unsigned int)std::max((int64_t)0, GetArg("-maxorphantx", DEFAULT_MAX_ORPHAN_TRANSACTIONS)); unsigned int nEvicted = LimitOrphanTxSize(nMaxOrphanTx); if (nEvicted > 0) - LogPrint("mempool", "mapOrphan overflow, removed %u tx\n", nEvicted); + LogPrint(BCLog::MEMPOOL, "mapOrphan overflow, removed %u tx\n", nEvicted); } else if (pfrom->fWhitelisted) { // Always relay transactions received from whitelisted peers, even // if they are already in the mempool (allowing the node to function @@ -5966,7 +5964,7 @@ bool static ProcessMessage(CNode* pfrom, std::string strCommand, CDataStream& vR int nDoS = 0; if (state.IsInvalid(nDoS)) { - LogPrint("mempool", "%s from peer=%d %s was not accepted into the memory pool: %s\n", tx.GetHash().ToString(), + LogPrint(BCLog::MEMPOOL, "%s from peer=%d %s was not accepted into the memory pool: %s\n", tx.GetHash().ToString(), pfrom->id, pfrom->cleanSubVer, state.GetRejectReason()); pfrom->PushMessage("reject", strCommand, state.GetRejectCode(), @@ -6042,7 +6040,7 @@ bool static ProcessMessage(CNode* pfrom, std::string strCommand, CDataStream& vR vRecv >> block; uint256 hashBlock = block.GetHash(); CInv inv(MSG_BLOCK, hashBlock); - LogPrint("net", "received block %s peer=%d\n", inv.hash.ToString(), pfrom->id); + LogPrint(BCLog::NET, "received block %s peer=%d\n", inv.hash.ToString(), pfrom->id); //sometimes we will be sent their most recent block and its not the one we want, in that case tell where we are if (!mapBlockIndex.count(block.hashPrevBlock)) { @@ -6073,7 +6071,7 @@ bool static ProcessMessage(CNode* pfrom, std::string strCommand, CDataStream& vR //disconnect this node if its old protocol version pfrom->DisconnectOldProtocol(ActiveProtocol(), strCommand); } else { - LogPrint("net", "%s : Already processed block %s, skipping ProcessNewBlock()\n", __func__, block.GetHash().GetHex()); + LogPrint(BCLog::NET, "%s : Already processed block %s, skipping ProcessNewBlock()\n", __func__, block.GetHash().GetHex()); } } } @@ -6178,7 +6176,7 @@ bool static ProcessMessage(CNode* pfrom, std::string strCommand, CDataStream& vR } if (!(sProblem.empty())) { - LogPrint("net", "pong peer=%d %s: %s, %x expected, %x received, %u bytes\n", + LogPrint(BCLog::NET, "pong peer=%d %s: %s, %x expected, %x received, %u bytes\n", pfrom->id, pfrom->cleanSubVer, sProblem, @@ -6248,26 +6246,24 @@ bool static ProcessMessage(CNode* pfrom, std::string strCommand, CDataStream& vR else if (strCommand == "reject") { - if (fDebug) { - try { - std::string strMsg; - unsigned char ccode; - std::string strReason; - vRecv >> LIMITED_STRING(strMsg, CMessageHeader::COMMAND_SIZE) >> ccode >> LIMITED_STRING(strReason, MAX_REJECT_MESSAGE_LENGTH); - - std::ostringstream ss; - ss << strMsg << " code " << itostr(ccode) << ": " << strReason; - - if (strMsg == "block" || strMsg == "tx") { - uint256 hash; - vRecv >> hash; - ss << ": hash " << hash.ToString(); - } - LogPrint("net", "Reject %s\n", SanitizeString(ss.str())); - } catch (const std::ios_base::failure& e) { - // Avoid feedback loops by preventing reject messages from triggering a new reject message. - LogPrint("net", "Unparseable reject message received\n"); + try { + std::string strMsg; + unsigned char ccode; + std::string strReason; + vRecv >> LIMITED_STRING(strMsg, CMessageHeader::COMMAND_SIZE) >> ccode >> LIMITED_STRING(strReason, MAX_REJECT_MESSAGE_LENGTH); + + std::ostringstream ss; + ss << strMsg << " code " << itostr(ccode) << ": " << strReason; + + if (strMsg == "block" || strMsg == "tx") { + uint256 hash; + vRecv >> hash; + ss << ": hash " << hash.ToString(); } + LogPrint(BCLog::NET, "Reject %s\n", SanitizeString(ss.str())); + } catch (const std::ios_base::failure& e) { + // Avoid feedback loops by preventing reject messages from triggering a new reject message. + LogPrint(BCLog::NET, "Unparseable reject message received\n"); } } else { //probably one the extensions @@ -6303,10 +6299,6 @@ int ActiveProtocol() // requires LOCK(cs_vRecvMsg) bool ProcessMessages(CNode* pfrom) { - //if (fDebug) - // LogPrintf("ProcessMessages(%u messages)\n", pfrom->vRecvMsg.size()); - - // // Message format // (4) message start // (12) command @@ -6331,11 +6323,6 @@ bool ProcessMessages(CNode* pfrom) // get next message CNetMessage& msg = *it; - //if (fDebug) - // LogPrintf("ProcessMessages(message %u msgsz, %u bytes, complete:%s)\n", - // msg.hdr.nMessageSize, msg.vRecv.size(), - // msg.complete() ? "Y" : "N"); - // end, if an incomplete message is found if (!msg.complete()) break; @@ -6517,7 +6504,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle) state.fSyncStarted = true; nSyncStarted++; //CBlockIndex *pindexStart = pindexBestHeader->pprev ? pindexBestHeader->pprev : pindexBestHeader; - //LogPrint("net", "initial getheaders (%d) to peer=%d (startheight:%d)\n", pindexStart->nHeight, pto->id, pto->nStartingHeight); + //LogPrint(BCLog::NET, "initial getheaders (%d) to peer=%d (startheight:%d)\n", pindexStart->nHeight, pto->id, pto->nStartingHeight); //pto->PushMessage("getheaders", chainActive.GetLocator(pindexStart), UINT256_ZERO); pto->PushMessage("getblocks", chainActive.GetLocator(chainActive.Tip()), UINT256_ZERO); } @@ -6609,7 +6596,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle) if (state.nBlocksInFlight == 0 && staller != -1) { if (State(staller)->nStallingSince == 0) { State(staller)->nStallingSince = nNow; - LogPrint("net", "Stall started peer=%d\n", staller); + LogPrint(BCLog::NET, "Stall started peer=%d\n", staller); } } } @@ -6620,8 +6607,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle) while (!pto->fDisconnect && !pto->mapAskFor.empty() && (*pto->mapAskFor.begin()).first <= nNow) { const CInv& inv = (*pto->mapAskFor.begin()).second; if (!AlreadyHave(inv)) { - if (fDebug) - LogPrint("net", "Requesting %s peer=%d\n", inv.ToString(), pto->id); + LogPrint(BCLog::NET, "Requesting %s peer=%d\n", inv.ToString(), pto->id); vGetData.push_back(inv); if (vGetData.size() >= 1000) { pto->PushMessage("getdata", vGetData); diff --git a/src/masternode-budget.cpp b/src/masternode-budget.cpp index c2f6110d10acc2..ee9c8efbc5f3c5 100644 --- a/src/masternode-budget.cpp +++ b/src/masternode-budget.cpp @@ -31,7 +31,7 @@ bool IsBudgetCollateralValid(uint256 nTxCollateralHash, uint256 nExpectedHash, s uint256 nBlockHash; if (!GetTransaction(nTxCollateralHash, txCollateral, nBlockHash, true)) { strError = strprintf("Can't find collateral tx %s", txCollateral.ToString()); - LogPrint("mnbudget","CBudgetProposalBroadcast::IsBudgetCollateralValid - %s\n", strError); + LogPrint(BCLog::MNBUDGET,"CBudgetProposalBroadcast::IsBudgetCollateralValid - %s\n", strError); return false; } @@ -45,16 +45,16 @@ bool IsBudgetCollateralValid(uint256 nTxCollateralHash, uint256 nExpectedHash, s for (const CTxOut &o : txCollateral.vout) { if (!o.scriptPubKey.IsNormalPaymentScript() && !o.scriptPubKey.IsUnspendable()) { strError = strprintf("Invalid Script %s", txCollateral.ToString()); - LogPrint("mnbudget","CBudgetProposalBroadcast::IsBudgetCollateralValid - %s\n", strError); + LogPrint(BCLog::MNBUDGET,"CBudgetProposalBroadcast::IsBudgetCollateralValid - %s\n", strError); return false; } if (fBudgetFinalization) { // Collateral for budget finalization // Note: there are still old valid budgets out there, but the check for the new 5 PIV finalization collateral // will also cover the old 50 PIV finalization collateral. - LogPrint("mnbudget", "Final Budget: o.scriptPubKey(%s) == findScript(%s) ?\n", o.scriptPubKey.ToString(), findScript.ToString()); + LogPrint(BCLog::MNBUDGET, "Final Budget: o.scriptPubKey(%s) == findScript(%s) ?\n", o.scriptPubKey.ToString(), findScript.ToString()); if (o.scriptPubKey == findScript) { - LogPrint("mnbudget", "Final Budget: o.nValue(%ld) >= BUDGET_FEE_TX(%ld) ?\n", o.nValue, BUDGET_FEE_TX); + LogPrint(BCLog::MNBUDGET, "Final Budget: o.nValue(%ld) >= BUDGET_FEE_TX(%ld) ?\n", o.nValue, BUDGET_FEE_TX); if(o.nValue >= BUDGET_FEE_TX) { foundOpReturn = true; } @@ -62,9 +62,9 @@ bool IsBudgetCollateralValid(uint256 nTxCollateralHash, uint256 nExpectedHash, s } else { // Collateral for normal budget proposal - LogPrint("mnbudget", "Normal Budget: o.scriptPubKey(%s) == findScript(%s) ?\n", o.scriptPubKey.ToString(), findScript.ToString()); + LogPrint(BCLog::MNBUDGET, "Normal Budget: o.scriptPubKey(%s) == findScript(%s) ?\n", o.scriptPubKey.ToString(), findScript.ToString()); if (o.scriptPubKey == findScript) { - LogPrint("mnbudget", "Normal Budget: o.nValue(%ld) >= PROPOSAL_FEE_TX(%ld) ?\n", o.nValue, PROPOSAL_FEE_TX); + LogPrint(BCLog::MNBUDGET, "Normal Budget: o.nValue(%ld) >= PROPOSAL_FEE_TX(%ld) ?\n", o.nValue, PROPOSAL_FEE_TX); if(o.nValue >= PROPOSAL_FEE_TX) { foundOpReturn = true; } @@ -73,7 +73,7 @@ bool IsBudgetCollateralValid(uint256 nTxCollateralHash, uint256 nExpectedHash, s } if (!foundOpReturn) { strError = strprintf("Couldn't find opReturn %s in %s", nExpectedHash.ToString(), txCollateral.ToString()); - LogPrint("mnbudget","CBudgetProposalBroadcast::IsBudgetCollateralValid - %s\n", strError); + LogPrint(BCLog::MNBUDGET,"CBudgetProposalBroadcast::IsBudgetCollateralValid - %s\n", strError); return false; } @@ -103,7 +103,7 @@ bool IsBudgetCollateralValid(uint256 nTxCollateralHash, uint256 nExpectedHash, s return true; } else { strError = strprintf("Collateral requires at least %d confirmations - %d confirmations", nRequiredConfs, conf); - LogPrint("mnbudget","CBudgetProposalBroadcast::IsBudgetCollateralValid - %s - %d confirmations\n", strError, conf); + LogPrint(BCLog::MNBUDGET,"CBudgetProposalBroadcast::IsBudgetCollateralValid - %s - %d confirmations\n", strError, conf); return false; } } @@ -117,7 +117,7 @@ void CBudgetManager::CheckOrphanVotes() std::map::iterator it1 = mapOrphanMasternodeBudgetVotes.begin(); while (it1 != mapOrphanMasternodeBudgetVotes.end()) { if (budget.UpdateProposal(((*it1).second), NULL, strError)) { - LogPrint("mnbudget","CBudgetManager::CheckOrphanVotes - Proposal/Budget is known, activating and removing orphan vote\n"); + LogPrint(BCLog::MNBUDGET,"CBudgetManager::CheckOrphanVotes - Proposal/Budget is known, activating and removing orphan vote\n"); mapOrphanMasternodeBudgetVotes.erase(it1++); } else { ++it1; @@ -126,13 +126,13 @@ void CBudgetManager::CheckOrphanVotes() std::map::iterator it2 = mapOrphanFinalizedBudgetVotes.begin(); while (it2 != mapOrphanFinalizedBudgetVotes.end()) { if (budget.UpdateFinalizedBudget(((*it2).second), NULL, strError)) { - LogPrint("mnbudget","CBudgetManager::CheckOrphanVotes - Proposal/Budget is known, activating and removing orphan vote\n"); + LogPrint(BCLog::MNBUDGET,"CBudgetManager::CheckOrphanVotes - Proposal/Budget is known, activating and removing orphan vote\n"); mapOrphanFinalizedBudgetVotes.erase(it2++); } else { ++it2; } } - LogPrint("mnbudget","CBudgetManager::CheckOrphanVotes - Done\n"); + LogPrint(BCLog::MNBUDGET,"CBudgetManager::CheckOrphanVotes - Done\n"); } void CBudgetManager::SubmitFinalBudget() @@ -150,7 +150,7 @@ void CBudgetManager::SubmitFinalBudget() const int nBlocksPerCycle = Params().GetConsensus().nBudgetCycleBlocks; int nBlockStart = nCurrentHeight - nCurrentHeight % nBlocksPerCycle + nBlocksPerCycle; if (nSubmittedHeight >= nBlockStart){ - LogPrint("mnbudget","CBudgetManager::SubmitFinalBudget - nSubmittedHeight(=%ld) < nBlockStart(=%ld) condition not fulfilled.\n", nSubmittedHeight, nBlockStart); + LogPrint(BCLog::MNBUDGET,"CBudgetManager::SubmitFinalBudget - nSubmittedHeight(=%ld) < nBlockStart(=%ld) condition not fulfilled.\n", nSubmittedHeight, nBlockStart); return; } @@ -169,8 +169,8 @@ void CBudgetManager::SubmitFinalBudget() int nOffsetToStart = nFinalizationStart - nCurrentHeight; if (nBlockStart - nCurrentHeight > finalizationWindow) { - LogPrint("mnbudget","CBudgetManager::SubmitFinalBudget - Too early for finalization. Current block is %ld, next Superblock is %ld.\n", nCurrentHeight, nBlockStart); - LogPrint("mnbudget","CBudgetManager::SubmitFinalBudget - First possible block for finalization: %ld. Last possible block for finalization: %ld. You have to wait for %ld block(s) until Budget finalization will be possible\n", nFinalizationStart, nBlockStart, nOffsetToStart); + LogPrint(BCLog::MNBUDGET,"CBudgetManager::SubmitFinalBudget - Too early for finalization. Current block is %ld, next Superblock is %ld.\n", nCurrentHeight, nBlockStart); + LogPrint(BCLog::MNBUDGET,"CBudgetManager::SubmitFinalBudget - First possible block for finalization: %ld. Last possible block for finalization: %ld. You have to wait for %ld block(s) until Budget finalization will be possible\n", nFinalizationStart, nBlockStart, nOffsetToStart); return; } @@ -188,13 +188,13 @@ void CBudgetManager::SubmitFinalBudget() } if (vecTxBudgetPayments.size() < 1) { - LogPrint("mnbudget","CBudgetManager::SubmitFinalBudget - Found No Proposals For Period\n"); + LogPrint(BCLog::MNBUDGET,"CBudgetManager::SubmitFinalBudget - Found No Proposals For Period\n"); return; } CFinalizedBudgetBroadcast tempBudget(strBudgetName, nBlockStart, vecTxBudgetPayments, UINT256_ZERO); if (mapSeenFinalizedBudgets.count(tempBudget.GetHash())) { - LogPrint("mnbudget","CBudgetManager::SubmitFinalBudget - Budget already exists - %s\n", tempBudget.GetHash().ToString()); + LogPrint(BCLog::MNBUDGET,"CBudgetManager::SubmitFinalBudget - Budget already exists - %s\n", tempBudget.GetHash().ToString()); nSubmittedHeight = nCurrentHeight; return; //already exists } @@ -206,7 +206,7 @@ void CBudgetManager::SubmitFinalBudget() if (!mapCollateralTxids.count(tempBudget.GetHash())) { CWalletTx wtx; if (!pwalletMain->GetBudgetFinalizationCollateralTX(wtx, tempBudget.GetHash(), false)) { - LogPrint("mnbudget","CBudgetManager::SubmitFinalBudget - Can't make collateral transaction\n"); + LogPrint(BCLog::MNBUDGET,"CBudgetManager::SubmitFinalBudget - Can't make collateral transaction\n"); return; } @@ -226,7 +226,7 @@ void CBudgetManager::SubmitFinalBudget() uint256 nBlockHash; if (!GetTransaction(txidCollateral, txCollateral, nBlockHash, true)) { - LogPrint("mnbudget","CBudgetManager::SubmitFinalBudget - Can't find collateral tx %s", txidCollateral.ToString()); + LogPrint(BCLog::MNBUDGET,"CBudgetManager::SubmitFinalBudget - Can't find collateral tx %s", txidCollateral.ToString()); return; } @@ -246,7 +246,7 @@ void CBudgetManager::SubmitFinalBudget() */ const int nRequiredConfs = Params().GetConsensus().nBudgetFeeConfirmations; if (conf < nRequiredConfs + 1) { - LogPrint("mnbudget","CBudgetManager::SubmitFinalBudget - Collateral requires at least %d confirmations - %s - %d confirmations\n", nRequiredConfs + 1, txidCollateral.ToString(), conf); + LogPrint(BCLog::MNBUDGET,"CBudgetManager::SubmitFinalBudget - Collateral requires at least %d confirmations - %s - %d confirmations\n", nRequiredConfs + 1, txidCollateral.ToString(), conf); return; } @@ -255,7 +255,7 @@ void CBudgetManager::SubmitFinalBudget() std::string strError = ""; if (!finalizedBudgetBroadcast.IsValid(strError)) { - LogPrint("mnbudget","CBudgetManager::SubmitFinalBudget - Invalid finalized budget - %s \n", strError); + LogPrint(BCLog::MNBUDGET,"CBudgetManager::SubmitFinalBudget - Invalid finalized budget - %s \n", strError); return; } @@ -264,7 +264,7 @@ void CBudgetManager::SubmitFinalBudget() finalizedBudgetBroadcast.Relay(); budget.AddFinalizedBudget(finalizedBudgetBroadcast); nSubmittedHeight = nCurrentHeight; - LogPrint("mnbudget","CBudgetManager::SubmitFinalBudget - Done! %s\n", finalizedBudgetBroadcast.GetHash().ToString()); + LogPrint(BCLog::MNBUDGET,"CBudgetManager::SubmitFinalBudget - Done! %s\n", finalizedBudgetBroadcast.GetHash().ToString()); } // @@ -305,7 +305,7 @@ bool CBudgetDB::Write(const CBudgetManager& objToSave) } fileout.fclose(); - LogPrint("mnbudget","Written info to budget.dat %dms\n", GetTimeMillis() - nStart); + LogPrint(BCLog::MNBUDGET,"Written info to budget.dat %dms\n", GetTimeMillis() - nStart); return true; } @@ -383,13 +383,13 @@ CBudgetDB::ReadResult CBudgetDB::Read(CBudgetManager& objToLoad, bool fDryRun) return IncorrectFormat; } - LogPrint("mnbudget","Loaded info from budget.dat %dms\n", GetTimeMillis() - nStart); - LogPrint("mnbudget"," %s\n", objToLoad.ToString()); + LogPrint(BCLog::MNBUDGET,"Loaded info from budget.dat %dms\n", GetTimeMillis() - nStart); + LogPrint(BCLog::MNBUDGET," %s\n", objToLoad.ToString()); if (!fDryRun) { - LogPrint("mnbudget","Budget manager - cleaning....\n"); + LogPrint(BCLog::MNBUDGET,"Budget manager - cleaning....\n"); objToLoad.CheckAndRemove(); - LogPrint("mnbudget","Budget manager - result:\n"); - LogPrint("mnbudget"," %s\n", objToLoad.ToString()); + LogPrint(BCLog::MNBUDGET,"Budget manager - result:\n"); + LogPrint(BCLog::MNBUDGET," %s\n", objToLoad.ToString()); } return Ok; @@ -402,24 +402,24 @@ void DumpBudgets() CBudgetDB budgetdb; CBudgetManager tempBudget; - LogPrint("mnbudget","Verifying budget.dat format...\n"); + LogPrint(BCLog::MNBUDGET,"Verifying budget.dat format...\n"); CBudgetDB::ReadResult readResult = budgetdb.Read(tempBudget, true); // there was an error and it was not an error on file opening => do not proceed if (readResult == CBudgetDB::FileError) - LogPrint("mnbudget","Missing budgets file - budget.dat, will try to recreate\n"); + LogPrint(BCLog::MNBUDGET,"Missing budgets file - budget.dat, will try to recreate\n"); else if (readResult != CBudgetDB::Ok) { - LogPrint("mnbudget","Error reading budget.dat: "); + LogPrint(BCLog::MNBUDGET,"Error reading budget.dat: "); if (readResult == CBudgetDB::IncorrectFormat) - LogPrint("mnbudget","magic is ok but data has invalid format, will try to recreate\n"); + LogPrint(BCLog::MNBUDGET,"magic is ok but data has invalid format, will try to recreate\n"); else { - LogPrint("mnbudget","file format is unknown or invalid, please fix it manually\n"); + LogPrint(BCLog::MNBUDGET,"file format is unknown or invalid, please fix it manually\n"); return; } } - LogPrint("mnbudget","Writting info to budget.dat...\n"); + LogPrint(BCLog::MNBUDGET,"Writting info to budget.dat...\n"); budgetdb.Write(budget); - LogPrint("mnbudget","Budget dump finished %dms\n", GetTimeMillis() - nStart); + LogPrint(BCLog::MNBUDGET,"Budget dump finished %dms\n", GetTimeMillis() - nStart); } bool CBudgetManager::AddFinalizedBudget(CFinalizedBudget& finalizedBudget) @@ -440,7 +440,7 @@ bool CBudgetManager::AddProposal(CBudgetProposal& budgetProposal) LOCK(cs); std::string strError = ""; if (!budgetProposal.IsValid(strError)) { - LogPrint("mnbudget","CBudgetManager::AddProposal - invalid budget proposal - %s\n", strError); + LogPrint(BCLog::MNBUDGET,"CBudgetManager::AddProposal - invalid budget proposal - %s\n", strError); return false; } @@ -449,7 +449,7 @@ bool CBudgetManager::AddProposal(CBudgetProposal& budgetProposal) } mapProposals.insert(std::make_pair(budgetProposal.GetHash(), budgetProposal)); - LogPrint("mnbudget","CBudgetManager::AddProposal - proposal %s added\n", budgetProposal.GetName ().c_str ()); + LogPrint(BCLog::MNBUDGET,"CBudgetManager::AddProposal - proposal %s added\n", budgetProposal.GetName ().c_str ()); return true; } @@ -468,24 +468,24 @@ void CBudgetManager::CheckAndRemove() } } - LogPrint("mnbudget", "CBudgetManager::CheckAndRemove at Height=%d\n", nHeight); + LogPrint(BCLog::MNBUDGET, "CBudgetManager::CheckAndRemove at Height=%d\n", nHeight); std::map tmpMapFinalizedBudgets; std::map tmpMapProposals; std::string strError = ""; - LogPrint("mnbudget", "CBudgetManager::CheckAndRemove - mapFinalizedBudgets cleanup - size before: %d\n", mapFinalizedBudgets.size()); + LogPrint(BCLog::MNBUDGET, "CBudgetManager::CheckAndRemove - mapFinalizedBudgets cleanup - size before: %d\n", mapFinalizedBudgets.size()); std::map::iterator it = mapFinalizedBudgets.begin(); while (it != mapFinalizedBudgets.end()) { CFinalizedBudget* pfinalizedBudget = &((*it).second); pfinalizedBudget->fValid = pfinalizedBudget->IsValid(strError); if (!strError.empty ()) { - LogPrint("mnbudget","CBudgetManager::CheckAndRemove - Invalid finalized budget: %s\n", strError); + LogPrint(BCLog::MNBUDGET,"CBudgetManager::CheckAndRemove - Invalid finalized budget: %s\n", strError); } else { - LogPrint("mnbudget","CBudgetManager::CheckAndRemove - Found valid finalized budget: %s %s\n", + LogPrint(BCLog::MNBUDGET,"CBudgetManager::CheckAndRemove - Found valid finalized budget: %s %s\n", pfinalizedBudget->strBudgetName.c_str(), pfinalizedBudget->nFeeTXHash.ToString().c_str()); } @@ -497,17 +497,17 @@ void CBudgetManager::CheckAndRemove() ++it; } - LogPrint("mnbudget", "CBudgetManager::CheckAndRemove - mapProposals cleanup - size before: %d\n", mapProposals.size()); + LogPrint(BCLog::MNBUDGET, "CBudgetManager::CheckAndRemove - mapProposals cleanup - size before: %d\n", mapProposals.size()); std::map::iterator it2 = mapProposals.begin(); while (it2 != mapProposals.end()) { CBudgetProposal* pbudgetProposal = &((*it2).second); pbudgetProposal->fValid = pbudgetProposal->IsValid(strError); if (!strError.empty ()) { - LogPrint("mnbudget","CBudgetManager::CheckAndRemove - Invalid budget proposal - %s\n", strError); + LogPrint(BCLog::MNBUDGET,"CBudgetManager::CheckAndRemove - Invalid budget proposal - %s\n", strError); strError = ""; } else { - LogPrint("mnbudget","CBudgetManager::CheckAndRemove - Found valid budget proposal: %s %s\n", + LogPrint(BCLog::MNBUDGET,"CBudgetManager::CheckAndRemove - Found valid budget proposal: %s %s\n", pbudgetProposal->strProposalName.c_str(), pbudgetProposal->nFeeTXHash.ToString().c_str()); } if (pbudgetProposal->fValid) { @@ -524,9 +524,9 @@ void CBudgetManager::CheckAndRemove() // mapFinalizedBudgets = tmpMapFinalizedBudgets; // mapProposals = tmpMapProposals; - LogPrint("mnbudget", "CBudgetManager::CheckAndRemove - mapFinalizedBudgets cleanup - size after: %d\n", mapFinalizedBudgets.size()); - LogPrint("mnbudget", "CBudgetManager::CheckAndRemove - mapProposals cleanup - size after: %d\n", mapProposals.size()); - LogPrint("mnbudget","CBudgetManager::CheckAndRemove - PASSED\n"); + LogPrint(BCLog::MNBUDGET, "CBudgetManager::CheckAndRemove - mapFinalizedBudgets cleanup - size after: %d\n", mapFinalizedBudgets.size()); + LogPrint(BCLog::MNBUDGET, "CBudgetManager::CheckAndRemove - mapProposals cleanup - size after: %d\n", mapProposals.size()); + LogPrint(BCLog::MNBUDGET,"CBudgetManager::CheckAndRemove - PASSED\n"); } @@ -568,10 +568,10 @@ void CBudgetManager::FillBlockPayee(CMutableTransaction& txNew, CAmount nFees, b CTxDestination address1; ExtractDestination(payee, address1); CBitcoinAddress address2(address1); - LogPrint("mnbudget","CBudgetManager::FillBlockPayee - Budget payment to %s for %lld, nHighestCount = %d\n", address2.ToString(), nAmount, nHighestCount); + LogPrint(BCLog::MNBUDGET,"CBudgetManager::FillBlockPayee - Budget payment to %s for %lld, nHighestCount = %d\n", address2.ToString(), nAmount, nHighestCount); } else { - LogPrint("mnbudget","CBudgetManager::FillBlockPayee - No Budget payment, nHighestCount = %d\n", nHighestCount); + LogPrint(BCLog::MNBUDGET,"CBudgetManager::FillBlockPayee - No Budget payment, nHighestCount = %d\n", nHighestCount); } } else { //miners get the full amount on these blocks @@ -588,7 +588,7 @@ void CBudgetManager::FillBlockPayee(CMutableTransaction& txNew, CAmount nFees, b ExtractDestination(payee, address1); CBitcoinAddress address2(address1); - LogPrint("mnbudget","CBudgetManager::FillBlockPayee - Budget payment to %s for %lld\n", address2.ToString(), nAmount); + LogPrint(BCLog::MNBUDGET,"CBudgetManager::FillBlockPayee - Budget payment to %s for %lld\n", address2.ToString(), nAmount); } } } @@ -649,7 +649,7 @@ bool CBudgetManager::IsBudgetPaymentBlock(int nBlockHeight) ++it; } - LogPrint("mnbudget","CBudgetManager::IsBudgetPaymentBlock() - nHighestCount: %lli, 5%% of Masternodes: %lli. Number of finalized budgets: %lli\n", + LogPrint(BCLog::MNBUDGET,"CBudgetManager::IsBudgetPaymentBlock() - nHighestCount: %lli, 5%% of Masternodes: %lli. Number of finalized budgets: %lli\n", nHighestCount, nFivePercent, mapFinalizedBudgets.size()); // If budget doesn't have 5% of the network votes, then we should pay a masternode instead @@ -667,7 +667,7 @@ TrxValidationStatus CBudgetManager::IsTransactionValid(const CTransaction& txNew int nFivePercent = mnodeman.CountEnabled(ActiveProtocol()) / 20; std::vector ret; - LogPrint("mnbudget","CBudgetManager::IsTransactionValid - checking %lli finalized budgets\n", mapFinalizedBudgets.size()); + LogPrint(BCLog::MNBUDGET,"CBudgetManager::IsTransactionValid - checking %lli finalized budgets\n", mapFinalizedBudgets.size()); // ------- Grab The Highest Count @@ -684,7 +684,7 @@ TrxValidationStatus CBudgetManager::IsTransactionValid(const CTransaction& txNew ++it; } - LogPrint("mnbudget","CBudgetManager::IsTransactionValid() - nHighestCount: %lli, 5%% of Masternodes: %lli mapFinalizedBudgets.size(): %ld\n", + LogPrint(BCLog::MNBUDGET,"CBudgetManager::IsTransactionValid() - nHighestCount: %lli, 5%% of Masternodes: %lli mapFinalizedBudgets.size(): %ld\n", nHighestCount, nFivePercent, mapFinalizedBudgets.size()); /* If budget doesn't have 5% of the network votes, then we should pay a masternode instead @@ -701,26 +701,26 @@ TrxValidationStatus CBudgetManager::IsTransactionValid(const CTransaction& txNew CFinalizedBudget* pfinalizedBudget = &((*it).second); strProposals = pfinalizedBudget->GetProposals(); - LogPrint("mnbudget","CBudgetManager::IsTransactionValid - checking budget (%s) with blockstart %lli, blockend %lli, nBlockHeight %lli, votes %lli, nCountThreshold %lli\n", + LogPrint(BCLog::MNBUDGET,"CBudgetManager::IsTransactionValid - checking budget (%s) with blockstart %lli, blockend %lli, nBlockHeight %lli, votes %lli, nCountThreshold %lli\n", strProposals.c_str(), pfinalizedBudget->GetBlockStart(), pfinalizedBudget->GetBlockEnd(), nBlockHeight, pfinalizedBudget->GetVoteCount(), nCountThreshold); if (pfinalizedBudget->GetVoteCount() > nCountThreshold) { fThreshold = true; - LogPrint("mnbudget","CBudgetManager::IsTransactionValid - GetVoteCount() > nCountThreshold passed\n"); + LogPrint(BCLog::MNBUDGET,"CBudgetManager::IsTransactionValid - GetVoteCount() > nCountThreshold passed\n"); if (nBlockHeight >= pfinalizedBudget->GetBlockStart() && nBlockHeight <= pfinalizedBudget->GetBlockEnd()) { - LogPrint("mnbudget","CBudgetManager::IsTransactionValid - GetBlockStart() passed\n"); + LogPrint(BCLog::MNBUDGET,"CBudgetManager::IsTransactionValid - GetBlockStart() passed\n"); transactionStatus = pfinalizedBudget->IsTransactionValid(txNew, nBlockHeight); if (transactionStatus == TrxValidationStatus::Valid) { - LogPrint("mnbudget","CBudgetManager::IsTransactionValid - pfinalizedBudget->IsTransactionValid() passed\n"); + LogPrint(BCLog::MNBUDGET,"CBudgetManager::IsTransactionValid - pfinalizedBudget->IsTransactionValid() passed\n"); return TrxValidationStatus::Valid; } else { - LogPrint("mnbudget","CBudgetManager::IsTransactionValid - pfinalizedBudget->IsTransactionValid() error\n"); + LogPrint(BCLog::MNBUDGET,"CBudgetManager::IsTransactionValid - pfinalizedBudget->IsTransactionValid() error\n"); } } else { - LogPrint("mnbudget","CBudgetManager::IsTransactionValid - GetBlockStart() failed, budget is outside current payment cycle and will be ignored.\n"); + LogPrint(BCLog::MNBUDGET,"CBudgetManager::IsTransactionValid - GetBlockStart() failed, budget is outside current payment cycle and will be ignored.\n"); } } @@ -809,10 +809,10 @@ std::vector CBudgetManager::GetBudget() while (it2 != vBudgetPorposalsSort.end()) { CBudgetProposal* pbudgetProposal = (*it2).first; - LogPrint("mnbudget","CBudgetManager::GetBudget() - Processing Budget %s\n", pbudgetProposal->strProposalName.c_str()); + LogPrint(BCLog::MNBUDGET,"CBudgetManager::GetBudget() - Processing Budget %s\n", pbudgetProposal->strProposalName.c_str()); //prop start/end should be inside this period if (pbudgetProposal->IsPassing(pindexPrev, nBlockStart, nBlockEnd, mnCount)) { - LogPrint("mnbudget","CBudgetManager::GetBudget() - Check 1 passed: valid=%d | %ld <= %ld | %ld >= %ld | Yeas=%d Nays=%d Count=%d | established=%d\n", + LogPrint(BCLog::MNBUDGET,"CBudgetManager::GetBudget() - Check 1 passed: valid=%d | %ld <= %ld | %ld >= %ld | Yeas=%d Nays=%d Count=%d | established=%d\n", pbudgetProposal->fValid, pbudgetProposal->nBlockStart, nBlockStart, pbudgetProposal->nBlockEnd, nBlockEnd, pbudgetProposal->GetYeas(), pbudgetProposal->GetNays(), mnCount / 10, pbudgetProposal->IsEstablished()); @@ -821,14 +821,14 @@ std::vector CBudgetManager::GetBudget() pbudgetProposal->SetAllotted(pbudgetProposal->GetAmount()); nBudgetAllocated += pbudgetProposal->GetAmount(); vBudgetProposalsRet.push_back(pbudgetProposal); - LogPrint("mnbudget","CBudgetManager::GetBudget() - Check 2 passed: Budget added\n"); + LogPrint(BCLog::MNBUDGET,"CBudgetManager::GetBudget() - Check 2 passed: Budget added\n"); } else { pbudgetProposal->SetAllotted(0); - LogPrint("mnbudget","CBudgetManager::GetBudget() - Check 2 failed: no amount allotted\n"); + LogPrint(BCLog::MNBUDGET,"CBudgetManager::GetBudget() - Check 2 failed: no amount allotted\n"); } } else { - LogPrint("mnbudget","CBudgetManager::GetBudget() - Check 1 failed: valid=%d | %ld <= %ld | %ld >= %ld | Yeas=%d Nays=%d Count=%d | established=%d\n", + LogPrint(BCLog::MNBUDGET,"CBudgetManager::GetBudget() - Check 1 failed: valid=%d | %ld <= %ld | %ld >= %ld | Yeas=%d Nays=%d Count=%d | established=%d\n", pbudgetProposal->fValid, pbudgetProposal->nBlockStart, nBlockStart, pbudgetProposal->nBlockEnd, nBlockEnd, pbudgetProposal->GetYeas(), pbudgetProposal->GetNays(), mnodeman.CountEnabled(ActiveProtocol()) / 10, pbudgetProposal->IsEstablished()); @@ -896,7 +896,7 @@ std::string CBudgetManager::GetRequiredPaymentsString(int nBlockHeight) ret += payment.nProposalHash.ToString(); } } else { - LogPrint("mnbudget","CBudgetManager::GetRequiredPaymentsString - Couldn't find budget payment for block %d\n", nBlockHeight); + LogPrint(BCLog::MNBUDGET,"CBudgetManager::GetRequiredPaymentsString - Couldn't find budget payment for block %d\n", nBlockHeight); } } @@ -968,7 +968,7 @@ void CBudgetManager::NewBlock() // incremental sync with our peers if (masternodeSync.IsSynced()) { - LogPrint("mnbudget","CBudgetManager::NewBlock - incremental sync started\n"); + LogPrint(BCLog::MNBUDGET,"CBudgetManager::NewBlock - incremental sync started\n"); if (chainActive.Height() % 1440 == rand() % 1440) { ClearSeen(); ResetSync(); @@ -987,7 +987,7 @@ void CBudgetManager::NewBlock() //remove invalid votes once in a while (we have to check the signatures and validity of every vote, somewhat CPU intensive) - LogPrint("mnbudget","CBudgetManager::NewBlock - askedForSourceProposalOrBudget cleanup - size: %d\n", askedForSourceProposalOrBudget.size()); + LogPrint(BCLog::MNBUDGET,"CBudgetManager::NewBlock - askedForSourceProposalOrBudget cleanup - size: %d\n", askedForSourceProposalOrBudget.size()); std::map::iterator it = askedForSourceProposalOrBudget.begin(); while (it != askedForSourceProposalOrBudget.end()) { if ((*it).second > GetTime() - (60 * 60 * 24)) { @@ -997,21 +997,21 @@ void CBudgetManager::NewBlock() } } - LogPrint("mnbudget","CBudgetManager::NewBlock - mapProposals cleanup - size: %d\n", mapProposals.size()); + LogPrint(BCLog::MNBUDGET,"CBudgetManager::NewBlock - mapProposals cleanup - size: %d\n", mapProposals.size()); std::map::iterator it2 = mapProposals.begin(); while (it2 != mapProposals.end()) { (*it2).second.CleanAndRemove(); ++it2; } - LogPrint("mnbudget","CBudgetManager::NewBlock - mapFinalizedBudgets cleanup - size: %d\n", mapFinalizedBudgets.size()); + LogPrint(BCLog::MNBUDGET,"CBudgetManager::NewBlock - mapFinalizedBudgets cleanup - size: %d\n", mapFinalizedBudgets.size()); std::map::iterator it3 = mapFinalizedBudgets.begin(); while (it3 != mapFinalizedBudgets.end()) { (*it3).second.CleanAndRemove(); ++it3; } - LogPrint("mnbudget","CBudgetManager::NewBlock - vecImmatureBudgetProposals cleanup - size: %d\n", vecImmatureBudgetProposals.size()); + LogPrint(BCLog::MNBUDGET,"CBudgetManager::NewBlock - vecImmatureBudgetProposals cleanup - size: %d\n", vecImmatureBudgetProposals.size()); std::vector::iterator it4 = vecImmatureBudgetProposals.begin(); while (it4 != vecImmatureBudgetProposals.end()) { std::string strError = ""; @@ -1022,7 +1022,7 @@ void CBudgetManager::NewBlock() } if (!(*it4).IsValid(strError)) { - LogPrint("mnbudget","mprop (immature) - invalid budget proposal - %s\n", strError); + LogPrint(BCLog::MNBUDGET,"mprop (immature) - invalid budget proposal - %s\n", strError); it4 = vecImmatureBudgetProposals.erase(it4); continue; } @@ -1032,11 +1032,11 @@ void CBudgetManager::NewBlock() (*it4).Relay(); } - LogPrint("mnbudget","mprop (immature) - new budget - %s\n", (*it4).GetHash().ToString()); + LogPrint(BCLog::MNBUDGET,"mprop (immature) - new budget - %s\n", (*it4).GetHash().ToString()); it4 = vecImmatureBudgetProposals.erase(it4); } - LogPrint("mnbudget","CBudgetManager::NewBlock - vecImmatureFinalizedBudgets cleanup - size: %d\n", vecImmatureFinalizedBudgets.size()); + LogPrint(BCLog::MNBUDGET,"CBudgetManager::NewBlock - vecImmatureFinalizedBudgets cleanup - size: %d\n", vecImmatureFinalizedBudgets.size()); std::vector::iterator it5 = vecImmatureFinalizedBudgets.begin(); while (it5 != vecImmatureFinalizedBudgets.end()) { std::string strError = ""; @@ -1047,12 +1047,12 @@ void CBudgetManager::NewBlock() } if (!(*it5).IsValid(strError)) { - LogPrint("mnbudget","fbs (immature) - invalid finalized budget - %s\n", strError); + LogPrint(BCLog::MNBUDGET,"fbs (immature) - invalid finalized budget - %s\n", strError); it5 = vecImmatureFinalizedBudgets.erase(it5); continue; } - LogPrint("mnbudget","fbs (immature) - new finalized budget - %s\n", (*it5).GetHash().ToString()); + LogPrint(BCLog::MNBUDGET,"fbs (immature) - new finalized budget - %s\n", (*it5).GetHash().ToString()); CFinalizedBudget finalizedBudget((*it5)); if (AddFinalizedBudget(finalizedBudget)) { @@ -1061,7 +1061,7 @@ void CBudgetManager::NewBlock() it5 = vecImmatureFinalizedBudgets.erase(it5); } - LogPrint("mnbudget","CBudgetManager::NewBlock - PASSED\n"); + LogPrint(BCLog::MNBUDGET,"CBudgetManager::NewBlock - PASSED\n"); } void CBudgetManager::ProcessMessage(CNode* pfrom, std::string& strCommand, CDataStream& vRecv) @@ -1079,7 +1079,7 @@ void CBudgetManager::ProcessMessage(CNode* pfrom, std::string& strCommand, CData if (Params().NetworkID() == CBaseChainParams::MAIN) { if (nProp.IsNull()) { if (pfrom->HasFulfilledRequest("mnvs")) { - LogPrint("mnbudget","mnvs - peer already asked me for the list\n"); + LogPrint(BCLog::MNBUDGET,"mnvs - peer already asked me for the list\n"); Misbehaving(pfrom->GetId(), 20); return; } @@ -1088,7 +1088,7 @@ void CBudgetManager::ProcessMessage(CNode* pfrom, std::string& strCommand, CData } Sync(pfrom, nProp); - LogPrint("mnbudget", "mnvs - Sent Masternode votes to peer %i\n", pfrom->GetId()); + LogPrint(BCLog::MNBUDGET, "mnvs - Sent Masternode votes to peer %i\n", pfrom->GetId()); } if (strCommand == "mprop") { //Masternode Proposal @@ -1103,7 +1103,7 @@ void CBudgetManager::ProcessMessage(CNode* pfrom, std::string& strCommand, CData std::string strError = ""; int nConf = 0; if (!IsBudgetCollateralValid(budgetProposalBroadcast.nFeeTXHash, budgetProposalBroadcast.GetHash(), strError, budgetProposalBroadcast.nTime, nConf)) { - LogPrint("mnbudget","Proposal FeeTX is not valid - %s - %s\n", budgetProposalBroadcast.nFeeTXHash.ToString(), strError); + LogPrint(BCLog::MNBUDGET,"Proposal FeeTX is not valid - %s - %s\n", budgetProposalBroadcast.nFeeTXHash.ToString(), strError); if (nConf >= 1) vecImmatureBudgetProposals.push_back(budgetProposalBroadcast); return; } @@ -1111,7 +1111,7 @@ void CBudgetManager::ProcessMessage(CNode* pfrom, std::string& strCommand, CData mapSeenMasternodeBudgetProposals.insert(std::make_pair(budgetProposalBroadcast.GetHash(), budgetProposalBroadcast)); if (!budgetProposalBroadcast.IsValid(strError)) { - LogPrint("mnbudget","mprop - invalid budget proposal - %s\n", strError); + LogPrint(BCLog::MNBUDGET,"mprop - invalid budget proposal - %s\n", strError); return; } @@ -1121,7 +1121,7 @@ void CBudgetManager::ProcessMessage(CNode* pfrom, std::string& strCommand, CData } masternodeSync.AddedBudgetItem(budgetProposalBroadcast.GetHash()); - LogPrint("mnbudget","mprop - new budget - %s\n", budgetProposalBroadcast.GetHash().ToString()); + LogPrint(BCLog::MNBUDGET,"mprop - new budget - %s\n", budgetProposalBroadcast.GetHash().ToString()); //We might have active votes for this proposal that are valid now CheckOrphanVotes(); @@ -1139,7 +1139,7 @@ void CBudgetManager::ProcessMessage(CNode* pfrom, std::string& strCommand, CData CMasternode* pmn = mnodeman.Find(vote.vin); if (pmn == NULL) { - LogPrint("mnbudget","mvote - unknown masternode - vin: %s\n", vote.vin.prevout.hash.ToString()); + LogPrint(BCLog::MNBUDGET,"mvote - unknown masternode - vin: %s\n", vote.vin.prevout.hash.ToString()); mnodeman.AskForMN(pfrom, vote.vin); return; } @@ -1162,7 +1162,7 @@ void CBudgetManager::ProcessMessage(CNode* pfrom, std::string& strCommand, CData masternodeSync.AddedBudgetItem(vote.GetHash()); } - LogPrint("mnbudget","mvote - new budget vote for budget %s - %s\n", vote.nProposalHash.ToString(), vote.GetHash().ToString()); + LogPrint(BCLog::MNBUDGET,"mvote - new budget vote for budget %s - %s\n", vote.nProposalHash.ToString(), vote.GetHash().ToString()); } if (strCommand == "fbs") { //Finalized Budget Suggestion @@ -1177,7 +1177,7 @@ void CBudgetManager::ProcessMessage(CNode* pfrom, std::string& strCommand, CData std::string strError = ""; int nConf = 0; if (!IsBudgetCollateralValid(finalizedBudgetBroadcast.nFeeTXHash, finalizedBudgetBroadcast.GetHash(), strError, finalizedBudgetBroadcast.nTime, nConf, true)) { - LogPrint("mnbudget","fbs - Finalized Budget FeeTX is not valid - %s - %s\n", finalizedBudgetBroadcast.nFeeTXHash.ToString(), strError); + LogPrint(BCLog::MNBUDGET,"fbs - Finalized Budget FeeTX is not valid - %s - %s\n", finalizedBudgetBroadcast.nFeeTXHash.ToString(), strError); if (nConf >= 1) vecImmatureFinalizedBudgets.push_back(finalizedBudgetBroadcast); return; @@ -1186,11 +1186,11 @@ void CBudgetManager::ProcessMessage(CNode* pfrom, std::string& strCommand, CData mapSeenFinalizedBudgets.insert(std::make_pair(finalizedBudgetBroadcast.GetHash(), finalizedBudgetBroadcast)); if (!finalizedBudgetBroadcast.IsValid(strError)) { - LogPrint("mnbudget","fbs - invalid finalized budget - %s\n", strError); + LogPrint(BCLog::MNBUDGET,"fbs - invalid finalized budget - %s\n", strError); return; } - LogPrint("mnbudget","fbs - new finalized budget - %s\n", finalizedBudgetBroadcast.GetHash().ToString()); + LogPrint(BCLog::MNBUDGET,"fbs - new finalized budget - %s\n", finalizedBudgetBroadcast.GetHash().ToString()); CFinalizedBudget finalizedBudget(finalizedBudgetBroadcast); if (AddFinalizedBudget(finalizedBudget)) { @@ -1214,7 +1214,7 @@ void CBudgetManager::ProcessMessage(CNode* pfrom, std::string& strCommand, CData CMasternode* pmn = mnodeman.Find(vote.vin); if (pmn == NULL) { - LogPrint("mnbudget", "fbvote - unknown masternode - vin: %s\n", vote.vin.prevout.hash.ToString()); + LogPrint(BCLog::MNBUDGET, "fbvote - unknown masternode - vin: %s\n", vote.vin.prevout.hash.ToString()); mnodeman.AskForMN(pfrom, vote.vin); return; } @@ -1235,9 +1235,9 @@ void CBudgetManager::ProcessMessage(CNode* pfrom, std::string& strCommand, CData vote.Relay(); masternodeSync.AddedBudgetItem(vote.GetHash()); - LogPrint("mnbudget","fbvote - new finalized budget vote - %s from masternode %s\n", vote.GetHash().ToString(), HexStr(pmn->pubKeyMasternode)); + LogPrint(BCLog::MNBUDGET,"fbvote - new finalized budget vote - %s from masternode %s\n", vote.GetHash().ToString(), HexStr(pmn->pubKeyMasternode)); } else { - LogPrint("mnbudget","fbvote - rejected finalized budget vote - %s from masternode %s - %s\n", vote.GetHash().ToString(), HexStr(pmn->pubKeyMasternode), strError); + LogPrint(BCLog::MNBUDGET,"fbvote - rejected finalized budget vote - %s from masternode %s - %s\n", vote.GetHash().ToString(), HexStr(pmn->pubKeyMasternode), strError); } } } @@ -1363,7 +1363,7 @@ void CBudgetManager::Sync(CNode* pfrom, uint256 nProp, bool fPartial) pfrom->PushMessage("ssc", MASTERNODE_SYNC_BUDGET_PROP, nInvCount); - LogPrint("mnbudget", "CBudgetManager::Sync - sent %d items\n", nInvCount); + LogPrint(BCLog::MNBUDGET, "CBudgetManager::Sync - sent %d items\n", nInvCount); nInvCount = 0; @@ -1390,7 +1390,7 @@ void CBudgetManager::Sync(CNode* pfrom, uint256 nProp, bool fPartial) } pfrom->PushMessage("ssc", MASTERNODE_SYNC_BUDGET_FIN, nInvCount); - LogPrint("mnbudget", "CBudgetManager::Sync - sent %d items\n", nInvCount); + LogPrint(BCLog::MNBUDGET, "CBudgetManager::Sync - sent %d items\n", nInvCount); } bool CBudgetManager::UpdateProposal(CBudgetVote& vote, CNode* pfrom, std::string& strError) @@ -1403,7 +1403,7 @@ bool CBudgetManager::UpdateProposal(CBudgetVote& vote, CNode* pfrom, std::string // otherwise we'll think a full sync succeeded when they return a result if (!masternodeSync.IsSynced()) return false; - LogPrint("mnbudget","CBudgetManager::UpdateProposal - Unknown proposal %d, asking for source proposal\n", vote.nProposalHash.ToString()); + LogPrint(BCLog::MNBUDGET,"CBudgetManager::UpdateProposal - Unknown proposal %d, asking for source proposal\n", vote.nProposalHash.ToString()); mapOrphanMasternodeBudgetVotes[vote.nProposalHash] = vote; if (!askedForSourceProposalOrBudget.count(vote.nProposalHash)) { @@ -1430,7 +1430,7 @@ bool CBudgetManager::UpdateFinalizedBudget(CFinalizedBudgetVote& vote, CNode* pf // otherwise we'll think a full sync succeeded when they return a result if (!masternodeSync.IsSynced()) return false; - LogPrint("mnbudget","CBudgetManager::UpdateFinalizedBudget - Unknown Finalized Proposal %s, asking for source budget\n", vote.nBudgetHash.ToString()); + LogPrint(BCLog::MNBUDGET,"CBudgetManager::UpdateFinalizedBudget - Unknown Finalized Proposal %s, asking for source budget\n", vote.nBudgetHash.ToString()); mapOrphanFinalizedBudgetVotes[vote.nBudgetHash] = vote; if (!askedForSourceProposalOrBudget.count(vote.nBudgetHash)) { @@ -1442,7 +1442,7 @@ bool CBudgetManager::UpdateFinalizedBudget(CFinalizedBudgetVote& vote, CNode* pf strError = "Finalized Budget " + vote.nBudgetHash.ToString() + " not found!"; return false; } - LogPrint("mnbudget","CBudgetManager::UpdateFinalizedBudget - Finalized Proposal %s added\n", vote.nBudgetHash.ToString()); + LogPrint(BCLog::MNBUDGET,"CBudgetManager::UpdateFinalizedBudget - Finalized Proposal %s added\n", vote.nBudgetHash.ToString()); return mapFinalizedBudgets[vote.nBudgetHash].AddOrUpdateVote(vote, strError); } @@ -1597,12 +1597,12 @@ bool CBudgetProposal::AddOrUpdateVote(CBudgetVote& vote, std::string& strError) if (mapVotes.count(hash)) { if (mapVotes[hash].nTime > vote.nTime) { strError = strprintf("new vote older than existing vote - %s\n", vote.GetHash().ToString()); - LogPrint("mnbudget", "CBudgetProposal::AddOrUpdateVote - %s\n", strError); + LogPrint(BCLog::MNBUDGET, "CBudgetProposal::AddOrUpdateVote - %s\n", strError); return false; } if (vote.nTime - mapVotes[hash].nTime < BUDGET_VOTE_UPDATE_MIN) { strError = strprintf("time between votes is too soon - %s - %lli sec < %lli sec\n", vote.GetHash().ToString(), vote.nTime - mapVotes[hash].nTime,BUDGET_VOTE_UPDATE_MIN); - LogPrint("mnbudget", "CBudgetProposal::AddOrUpdateVote - %s\n", strError); + LogPrint(BCLog::MNBUDGET, "CBudgetProposal::AddOrUpdateVote - %s\n", strError); return false; } strAction = "Existing vote updated:"; @@ -1610,12 +1610,12 @@ bool CBudgetProposal::AddOrUpdateVote(CBudgetVote& vote, std::string& strError) if (vote.nTime > GetTime() + (60 * 60)) { strError = strprintf("new vote is too far ahead of current time - %s - nTime %lli - Max Time %lli\n", vote.GetHash().ToString(), vote.nTime, GetTime() + (60 * 60)); - LogPrint("mnbudget", "CBudgetProposal::AddOrUpdateVote - %s\n", strError); + LogPrint(BCLog::MNBUDGET, "CBudgetProposal::AddOrUpdateVote - %s\n", strError); return false; } mapVotes[hash] = vote; - LogPrint("mnbudget", "CBudgetProposal::AddOrUpdateVote - %s %s\n", strAction.c_str(), vote.GetHash().ToString().c_str()); + LogPrint(BCLog::MNBUDGET, "CBudgetProposal::AddOrUpdateVote - %s %s\n", strAction.c_str(), vote.GetHash().ToString().c_str()); return true; } @@ -1836,12 +1836,12 @@ bool CFinalizedBudget::AddOrUpdateVote(CFinalizedBudgetVote& vote, std::string& if (mapVotes.count(hash)) { if (mapVotes[hash].nTime > vote.nTime) { strError = strprintf("new vote older than existing vote - %s\n", vote.GetHash().ToString()); - LogPrint("mnbudget", "CFinalizedBudget::AddOrUpdateVote - %s\n", strError); + LogPrint(BCLog::MNBUDGET, "CFinalizedBudget::AddOrUpdateVote - %s\n", strError); return false; } if (vote.nTime - mapVotes[hash].nTime < BUDGET_VOTE_UPDATE_MIN) { strError = strprintf("time between votes is too soon - %s - %lli sec < %lli sec\n", vote.GetHash().ToString(), vote.nTime - mapVotes[hash].nTime,BUDGET_VOTE_UPDATE_MIN); - LogPrint("mnbudget", "CFinalizedBudget::AddOrUpdateVote - %s\n", strError); + LogPrint(BCLog::MNBUDGET, "CFinalizedBudget::AddOrUpdateVote - %s\n", strError); return false; } strAction = "Existing vote updated:"; @@ -1849,12 +1849,12 @@ bool CFinalizedBudget::AddOrUpdateVote(CFinalizedBudgetVote& vote, std::string& if (vote.nTime > GetTime() + (60 * 60)) { strError = strprintf("new vote is too far ahead of current time - %s - nTime %lli - Max Time %lli\n", vote.GetHash().ToString(), vote.nTime, GetTime() + (60 * 60)); - LogPrint("mnbudget", "CFinalizedBudget::AddOrUpdateVote - %s\n", strError); + LogPrint(BCLog::MNBUDGET, "CFinalizedBudget::AddOrUpdateVote - %s\n", strError); return false; } mapVotes[hash] = vote; - LogPrint("mnbudget", "CFinalizedBudget::AddOrUpdateVote - %s %s\n", strAction.c_str(), vote.GetHash().ToString().c_str()); + LogPrint(BCLog::MNBUDGET, "CFinalizedBudget::AddOrUpdateVote - %s %s\n", strAction.c_str(), vote.GetHash().ToString().c_str()); return true; } @@ -1882,17 +1882,17 @@ void CFinalizedBudget::CheckAndVote() CBlockIndex* pindexPrev = chainActive.Tip(); if (!pindexPrev) return; - LogPrint("mnbudget","CFinalizedBudget::AutoCheck - %lli - %d\n", pindexPrev->nHeight, fAutoChecked); + LogPrint(BCLog::MNBUDGET,"CFinalizedBudget::AutoCheck - %lli - %d\n", pindexPrev->nHeight, fAutoChecked); if (!fMasterNode || fAutoChecked) { - LogPrint("mnbudget","CFinalizedBudget::AutoCheck fMasterNode=%d fAutoChecked=%d\n", fMasterNode, fAutoChecked); + LogPrint(BCLog::MNBUDGET,"CFinalizedBudget::AutoCheck fMasterNode=%d fAutoChecked=%d\n", fMasterNode, fAutoChecked); return; } // Do this 1 in 4 blocks -- spread out the voting activity // -- this function is only called every fourteenth block, so this is really 1 in 56 blocks if (rand() % 4 != 0) { - LogPrint("mnbudget","CFinalizedBudget::AutoCheck - waiting\n"); + LogPrint(BCLog::MNBUDGET,"CFinalizedBudget::AutoCheck - waiting\n"); return; } @@ -1915,52 +1915,52 @@ void CFinalizedBudget::CheckAndVote() std::sort(vecBudgetPaymentsSortedByHash.begin(), vecBudgetPaymentsSortedByHash.end(), sortPaymentsByHash()); for (unsigned int i = 0; i < vecBudgetPaymentsSortedByHash.size(); i++) { - LogPrint("mnbudget","CFinalizedBudget::AutoCheck Budget-Payments - nProp %d %s\n", i, vecBudgetPaymentsSortedByHash[i].nProposalHash.ToString()); - LogPrint("mnbudget","CFinalizedBudget::AutoCheck Budget-Payments - Payee %d %s\n", i, vecBudgetPaymentsSortedByHash[i].payee.ToString()); - LogPrint("mnbudget","CFinalizedBudget::AutoCheck Budget-Payments - nAmount %d %lli\n", i, vecBudgetPaymentsSortedByHash[i].nAmount); + LogPrint(BCLog::MNBUDGET,"CFinalizedBudget::AutoCheck Budget-Payments - nProp %d %s\n", i, vecBudgetPaymentsSortedByHash[i].nProposalHash.ToString()); + LogPrint(BCLog::MNBUDGET,"CFinalizedBudget::AutoCheck Budget-Payments - Payee %d %s\n", i, vecBudgetPaymentsSortedByHash[i].payee.ToString()); + LogPrint(BCLog::MNBUDGET,"CFinalizedBudget::AutoCheck Budget-Payments - nAmount %d %lli\n", i, vecBudgetPaymentsSortedByHash[i].nAmount); } for (unsigned int i = 0; i < vBudgetProposalsSortedByHash.size(); i++) { - LogPrint("mnbudget","CFinalizedBudget::AutoCheck Budget-Proposals - nProp %d %s\n", i, vBudgetProposalsSortedByHash[i]->GetHash().ToString()); - LogPrint("mnbudget","CFinalizedBudget::AutoCheck Budget-Proposals - Payee %d %s\n", i, vBudgetProposalsSortedByHash[i]->GetPayee().ToString()); - LogPrint("mnbudget","CFinalizedBudget::AutoCheck Budget-Proposals - nAmount %d %lli\n", i, vBudgetProposalsSortedByHash[i]->GetAmount()); + LogPrint(BCLog::MNBUDGET,"CFinalizedBudget::AutoCheck Budget-Proposals - nProp %d %s\n", i, vBudgetProposalsSortedByHash[i]->GetHash().ToString()); + LogPrint(BCLog::MNBUDGET,"CFinalizedBudget::AutoCheck Budget-Proposals - Payee %d %s\n", i, vBudgetProposalsSortedByHash[i]->GetPayee().ToString()); + LogPrint(BCLog::MNBUDGET,"CFinalizedBudget::AutoCheck Budget-Proposals - nAmount %d %lli\n", i, vBudgetProposalsSortedByHash[i]->GetAmount()); } if (vBudgetProposalsSortedByHash.size() == 0) { - LogPrint("mnbudget","CFinalizedBudget::AutoCheck - No Budget-Proposals found, aborting\n"); + LogPrint(BCLog::MNBUDGET,"CFinalizedBudget::AutoCheck - No Budget-Proposals found, aborting\n"); return; } if (vBudgetProposalsSortedByHash.size() != vecBudgetPaymentsSortedByHash.size()) { - LogPrint("mnbudget","CFinalizedBudget::AutoCheck - Budget-Proposal length (%ld) doesn't match Budget-Payment length (%ld).\n", + LogPrint(BCLog::MNBUDGET,"CFinalizedBudget::AutoCheck - Budget-Proposal length (%ld) doesn't match Budget-Payment length (%ld).\n", vBudgetProposalsSortedByHash.size(), vecBudgetPaymentsSortedByHash.size()); return; } for (unsigned int i = 0; i < vecBudgetPaymentsSortedByHash.size(); i++) { if (i > vBudgetProposalsSortedByHash.size() - 1) { - LogPrint("mnbudget","CFinalizedBudget::AutoCheck - Proposal size mismatch, i=%d > (vBudgetProposals.size() - 1)=%d\n", i, vBudgetProposalsSortedByHash.size() - 1); + LogPrint(BCLog::MNBUDGET,"CFinalizedBudget::AutoCheck - Proposal size mismatch, i=%d > (vBudgetProposals.size() - 1)=%d\n", i, vBudgetProposalsSortedByHash.size() - 1); return; } if (vecBudgetPaymentsSortedByHash[i].nProposalHash != vBudgetProposalsSortedByHash[i]->GetHash()) { - LogPrint("mnbudget","CFinalizedBudget::AutoCheck - item #%d doesn't match %s %s\n", i, vecBudgetPaymentsSortedByHash[i].nProposalHash.ToString(), vBudgetProposalsSortedByHash[i]->GetHash().ToString()); + LogPrint(BCLog::MNBUDGET,"CFinalizedBudget::AutoCheck - item #%d doesn't match %s %s\n", i, vecBudgetPaymentsSortedByHash[i].nProposalHash.ToString(), vBudgetProposalsSortedByHash[i]->GetHash().ToString()); return; } // if(vecBudgetPayments[i].payee != vBudgetProposals[i]->GetPayee()){ -- triggered with false positive if (vecBudgetPaymentsSortedByHash[i].payee.ToString() != vBudgetProposalsSortedByHash[i]->GetPayee().ToString()) { - LogPrint("mnbudget","CFinalizedBudget::AutoCheck - item #%d payee doesn't match %s %s\n", i, vecBudgetPaymentsSortedByHash[i].payee.ToString(), vBudgetProposalsSortedByHash[i]->GetPayee().ToString()); + LogPrint(BCLog::MNBUDGET,"CFinalizedBudget::AutoCheck - item #%d payee doesn't match %s %s\n", i, vecBudgetPaymentsSortedByHash[i].payee.ToString(), vBudgetProposalsSortedByHash[i]->GetPayee().ToString()); return; } if (vecBudgetPaymentsSortedByHash[i].nAmount != vBudgetProposalsSortedByHash[i]->GetAmount()) { - LogPrint("mnbudget","CFinalizedBudget::AutoCheck - item #%d payee doesn't match %lli %lli\n", i, vecBudgetPaymentsSortedByHash[i].nAmount, vBudgetProposalsSortedByHash[i]->GetAmount()); + LogPrint(BCLog::MNBUDGET,"CFinalizedBudget::AutoCheck - item #%d payee doesn't match %lli %lli\n", i, vecBudgetPaymentsSortedByHash[i].nAmount, vBudgetProposalsSortedByHash[i]->GetAmount()); return; } } - LogPrint("mnbudget","CFinalizedBudget::AutoCheck - Finalized Budget Matches! Submitting Vote.\n"); + LogPrint(BCLog::MNBUDGET,"CFinalizedBudget::AutoCheck - Finalized Budget Matches! Submitting Vote.\n"); SubmitVote(); } } @@ -2016,7 +2016,7 @@ std::string CFinalizedBudget::GetStatus() for (int nBlockHeight = GetBlockStart(); nBlockHeight <= GetBlockEnd(); nBlockHeight++) { CTxBudgetPayment budgetPayment; if (!GetBudgetPaymentByBlock(nBlockHeight, budgetPayment)) { - LogPrint("mnbudget","CFinalizedBudget::GetStatus - Couldn't find budget payment for block %lld\n", nBlockHeight); + LogPrint(BCLog::MNBUDGET,"CFinalizedBudget::GetStatus - Couldn't find budget payment for block %lld\n", nBlockHeight); continue; } @@ -2125,7 +2125,7 @@ bool CFinalizedBudget::IsPaidAlready(uint256 nProposalHash, int nBlockHeight) nPaidBlockHeight = (*it).second; if((nPaidBlockHeight < GetBlockStart()) || (nPaidBlockHeight > GetBlockEnd())) { nOldProposalHash = (*it).first; - LogPrint("mnbudget", "CFinalizedBudget::IsPaidAlready - Budget Proposal %s, Block %d from old cycle deleted\n", + LogPrint(BCLog::MNBUDGET, "CFinalizedBudget::IsPaidAlready - Budget Proposal %s, Block %d from old cycle deleted\n", nOldProposalHash.ToString().c_str(), nPaidBlockHeight); mapPayment_History.erase(it++); } @@ -2138,7 +2138,7 @@ bool CFinalizedBudget::IsPaidAlready(uint256 nProposalHash, int nBlockHeight) if(mapPayment_History.count(nProposalHash) == 0) { // New proposal payment, insert into map for checks with later blocks from this cycle mapPayment_History.insert(std::pair(nProposalHash, nBlockHeight)); - LogPrint("mnbudget", "CFinalizedBudget::IsPaidAlready - Budget Proposal %s, Block %d added to payment history\n", + LogPrint(BCLog::MNBUDGET, "CFinalizedBudget::IsPaidAlready - Budget Proposal %s, Block %d added to payment history\n", nProposalHash.ToString().c_str(), nBlockHeight); return false; } @@ -2151,19 +2151,19 @@ TrxValidationStatus CFinalizedBudget::IsTransactionValid(const CTransaction& txN TrxValidationStatus transactionStatus = TrxValidationStatus::InValid; int nCurrentBudgetPayment = nBlockHeight - GetBlockStart(); if (nCurrentBudgetPayment < 0) { - LogPrint("mnbudget","CFinalizedBudget::IsTransactionValid - Invalid block - height: %d start: %d\n", nBlockHeight, GetBlockStart()); + LogPrint(BCLog::MNBUDGET,"CFinalizedBudget::IsTransactionValid - Invalid block - height: %d start: %d\n", nBlockHeight, GetBlockStart()); return TrxValidationStatus::InValid; } if (nCurrentBudgetPayment > (int)vecBudgetPayments.size() - 1) { - LogPrint("mnbudget","CFinalizedBudget::IsTransactionValid - Invalid last block - current budget payment: %d of %d\n", nCurrentBudgetPayment + 1, (int)vecBudgetPayments.size()); + LogPrint(BCLog::MNBUDGET,"CFinalizedBudget::IsTransactionValid - Invalid last block - current budget payment: %d of %d\n", nCurrentBudgetPayment + 1, (int)vecBudgetPayments.size()); return TrxValidationStatus::InValid; } bool paid = false; for (CTxOut out : txNew.vout) { - LogPrint("mnbudget","CFinalizedBudget::IsTransactionValid - nCurrentBudgetPayment=%d, payee=%s == out.scriptPubKey=%s, amount=%ld == out.nValue=%ld\n", + LogPrint(BCLog::MNBUDGET,"CFinalizedBudget::IsTransactionValid - nCurrentBudgetPayment=%d, payee=%s == out.scriptPubKey=%s, amount=%ld == out.nValue=%ld\n", nCurrentBudgetPayment, vecBudgetPayments[nCurrentBudgetPayment].payee.ToString().c_str(), out.scriptPubKey.ToString().c_str(), vecBudgetPayments[nCurrentBudgetPayment].nAmount, out.nValue); @@ -2171,7 +2171,7 @@ TrxValidationStatus CFinalizedBudget::IsTransactionValid(const CTransaction& txN // Check if this proposal was paid already. If so, pay a masternode instead paid = IsPaidAlready(vecBudgetPayments[nCurrentBudgetPayment].nProposalHash, nBlockHeight); if(paid) { - LogPrint("mnbudget","CFinalizedBudget::IsTransactionValid - Double Budget Payment of %d for proposal %d detected. Paying a masternode instead.\n", + LogPrint(BCLog::MNBUDGET,"CFinalizedBudget::IsTransactionValid - Double Budget Payment of %d for proposal %d detected. Paying a masternode instead.\n", vecBudgetPayments[nCurrentBudgetPayment].nAmount, vecBudgetPayments[nCurrentBudgetPayment].nProposalHash.GetHex()); // No matter what we've found before, stop all checks here. In future releases there might be more than one budget payment // per block, so even if the first one was not paid yet this one disables all budget payments for this block. @@ -2180,7 +2180,7 @@ TrxValidationStatus CFinalizedBudget::IsTransactionValid(const CTransaction& txN } else { transactionStatus = TrxValidationStatus::Valid; - LogPrint("mnbudget","CFinalizedBudget::IsTransactionValid - Found valid Budget Payment of %d for proposal %d\n", + LogPrint(BCLog::MNBUDGET,"CFinalizedBudget::IsTransactionValid - Found valid Budget Payment of %d for proposal %d\n", vecBudgetPayments[nCurrentBudgetPayment].nAmount, vecBudgetPayments[nCurrentBudgetPayment].nProposalHash.GetHex()); } } @@ -2191,7 +2191,7 @@ TrxValidationStatus CFinalizedBudget::IsTransactionValid(const CTransaction& txN ExtractDestination(vecBudgetPayments[nCurrentBudgetPayment].payee, address1); CBitcoinAddress address2(address1); - LogPrint("mnbudget","CFinalizedBudget::IsTransactionValid - Missing required payment - %s: %d c: %d\n", + LogPrint(BCLog::MNBUDGET,"CFinalizedBudget::IsTransactionValid - Missing required payment - %s: %d c: %d\n", address2.ToString(), vecBudgetPayments[nCurrentBudgetPayment].nAmount, nCurrentBudgetPayment); } @@ -2211,23 +2211,23 @@ void CFinalizedBudget::SubmitVote() } if (!CMessageSigner::GetKeysFromSecret(strMasterNodePrivKey, keyMasternode, pubKeyMasternode)) { - LogPrint("mnbudget","CFinalizedBudget::SubmitVote - Error upon calling GetKeysFromSecret\n"); + LogPrint(BCLog::MNBUDGET,"CFinalizedBudget::SubmitVote - Error upon calling GetKeysFromSecret\n"); return; } CFinalizedBudgetVote vote(activeMasternode.vin, GetHash()); if (!vote.Sign(keyMasternode, pubKeyMasternode, fNewSigs)) { - LogPrint("mnbudget","CFinalizedBudget::SubmitVote - Failure to sign."); + LogPrint(BCLog::MNBUDGET,"CFinalizedBudget::SubmitVote - Failure to sign."); return; } if (budget.UpdateFinalizedBudget(vote, NULL, strError)) { - LogPrint("mnbudget","CFinalizedBudget::SubmitVote - new finalized budget vote - %s\n", vote.GetHash().ToString()); + LogPrint(BCLog::MNBUDGET,"CFinalizedBudget::SubmitVote - new finalized budget vote - %s\n", vote.GetHash().ToString()); budget.mapSeenFinalizedBudgetVotes.insert(std::make_pair(vote.GetHash(), vote)); vote.Relay(); } else { - LogPrint("mnbudget","CFinalizedBudget::SubmitVote : Error submitting vote - %s\n", strError); + LogPrint(BCLog::MNBUDGET,"CFinalizedBudget::SubmitVote : Error submitting vote - %s\n", strError); } } diff --git a/src/masternode-payments.cpp b/src/masternode-payments.cpp index dd4f26fcbde77c..7c4b2b5ecf9361 100644 --- a/src/masternode-payments.cpp +++ b/src/masternode-payments.cpp @@ -59,7 +59,7 @@ bool CMasternodePaymentDB::Write(const CMasternodePayments& objToSave) } fileout.fclose(); - LogPrint("masternode","Written info to mnpayments.dat %dms\n", GetTimeMillis() - nStart); + LogPrint(BCLog::MASTERNODE,"Written info to mnpayments.dat %dms\n", GetTimeMillis() - nStart); return true; } @@ -134,13 +134,13 @@ CMasternodePaymentDB::ReadResult CMasternodePaymentDB::Read(CMasternodePayments& return IncorrectFormat; } - LogPrint("masternode","Loaded info from mnpayments.dat %dms\n", GetTimeMillis() - nStart); - LogPrint("masternode"," %s\n", objToLoad.ToString()); + LogPrint(BCLog::MASTERNODE,"Loaded info from mnpayments.dat %dms\n", GetTimeMillis() - nStart); + LogPrint(BCLog::MASTERNODE," %s\n", objToLoad.ToString()); if (!fDryRun) { - LogPrint("masternode","Masternode payments manager - cleaning....\n"); + LogPrint(BCLog::MASTERNODE,"Masternode payments manager - cleaning....\n"); objToLoad.CleanPaymentList(); - LogPrint("masternode","Masternode payments manager - result:\n"); - LogPrint("masternode"," %s\n", objToLoad.ToString()); + LogPrint(BCLog::MASTERNODE,"Masternode payments manager - result:\n"); + LogPrint(BCLog::MASTERNODE," %s\n", objToLoad.ToString()); } return Ok; @@ -166,14 +166,14 @@ bool CMasternodePaymentWinner::IsValid(CNode* pnode, std::string& strError) if (!pmn) { strError = strprintf("Unknown Masternode %s", vinMasternode.prevout.hash.ToString()); - LogPrint("masternode","CMasternodePaymentWinner::IsValid - %s\n", strError); + LogPrint(BCLog::MASTERNODE,"CMasternodePaymentWinner::IsValid - %s\n", strError); mnodeman.AskForMN(pnode, vinMasternode); return false; } if (pmn->protocolVersion < ActiveProtocol()) { strError = strprintf("Masternode protocol too old %d - req %d", pmn->protocolVersion, ActiveProtocol()); - LogPrint("masternode","CMasternodePaymentWinner::IsValid - %s\n", strError); + LogPrint(BCLog::MASTERNODE,"CMasternodePaymentWinner::IsValid - %s\n", strError); return false; } @@ -184,7 +184,7 @@ bool CMasternodePaymentWinner::IsValid(CNode* pnode, std::string& strError) // We don't want to print all of these messages, or punish them unless they're way off if (n > MNPAYMENTS_SIGNATURES_TOTAL * 2) { strError = strprintf("Masternode not in the top %d (%d)", MNPAYMENTS_SIGNATURES_TOTAL * 2, n); - LogPrint("masternode","CMasternodePaymentWinner::IsValid - %s\n", strError); + LogPrint(BCLog::MASTERNODE,"CMasternodePaymentWinner::IsValid - %s\n", strError); //if (masternodeSync.IsSynced()) Misbehaving(pnode->GetId(), 20); } return false; @@ -206,24 +206,24 @@ void DumpMasternodePayments() CMasternodePaymentDB paymentdb; CMasternodePayments tempPayments; - LogPrint("masternode","Verifying mnpayments.dat format...\n"); + LogPrint(BCLog::MASTERNODE,"Verifying mnpayments.dat format...\n"); CMasternodePaymentDB::ReadResult readResult = paymentdb.Read(tempPayments, true); // there was an error and it was not an error on file opening => do not proceed if (readResult == CMasternodePaymentDB::FileError) - LogPrint("masternode","Missing budgets file - mnpayments.dat, will try to recreate\n"); + LogPrint(BCLog::MASTERNODE,"Missing budgets file - mnpayments.dat, will try to recreate\n"); else if (readResult != CMasternodePaymentDB::Ok) { - LogPrint("masternode","Error reading mnpayments.dat: "); + LogPrint(BCLog::MASTERNODE,"Error reading mnpayments.dat: "); if (readResult == CMasternodePaymentDB::IncorrectFormat) - LogPrint("masternode","magic is ok but data has invalid format, will try to recreate\n"); + LogPrint(BCLog::MASTERNODE,"magic is ok but data has invalid format, will try to recreate\n"); else { - LogPrint("masternode","file format is unknown or invalid, please fix it manually\n"); + LogPrint(BCLog::MASTERNODE,"file format is unknown or invalid, please fix it manually\n"); return; } } - LogPrint("masternode","Writting info to mnpayments.dat...\n"); + LogPrint(BCLog::MASTERNODE,"Writting info to mnpayments.dat...\n"); paymentdb.Write(masternodePayments); - LogPrint("masternode","Budget dump finished %dms\n", GetTimeMillis() - nStart); + LogPrint(BCLog::MASTERNODE,"Budget dump finished %dms\n", GetTimeMillis() - nStart); } bool IsBlockValueValid(const CBlock& block, CAmount nExpectedValue, CAmount nMinted) @@ -241,7 +241,7 @@ bool IsBlockValueValid(const CBlock& block, CAmount nExpectedValue, CAmount nMin } if (nHeight == 0) { - LogPrint("masternode","IsBlockValueValid() : WARNING: Couldn't find previous block\n"); + LogPrint(BCLog::MASTERNODE,"IsBlockValueValid() : WARNING: Couldn't find previous block\n"); } //LogPrintf("XX69----------> IsBlockValueValid(): nMinted: %d, nExpectedValue: %d\n", FormatMoney(nMinted), FormatMoney(nExpectedValue)); @@ -280,7 +280,7 @@ bool IsBlockPayeeValid(const CBlock& block, int nBlockHeight) TrxValidationStatus transactionStatus = TrxValidationStatus::InValid; if (!masternodeSync.IsSynced()) { //there is no budget data to use to check anything -- find the longest chain - LogPrint("mnpayments", "Client not synced, skipping block payee checks\n"); + LogPrint(BCLog::MASTERNODE, "Client not synced, skipping block payee checks\n"); return true; } @@ -295,11 +295,11 @@ bool IsBlockPayeeValid(const CBlock& block, int nBlockHeight) } if (transactionStatus == TrxValidationStatus::InValid) { - LogPrint("masternode","Invalid budget payment detected %s\n", txNew.ToString().c_str()); + LogPrint(BCLog::MASTERNODE,"Invalid budget payment detected %s\n", txNew.ToString().c_str()); if (sporkManager.IsSporkActive(SPORK_9_MASTERNODE_BUDGET_ENFORCEMENT)) return false; - LogPrint("masternode","Budget enforcement is disabled, accepting block\n"); + LogPrint(BCLog::MASTERNODE,"Budget enforcement is disabled, accepting block\n"); } } } @@ -312,11 +312,11 @@ bool IsBlockPayeeValid(const CBlock& block, int nBlockHeight) //check for masternode payee if (masternodePayments.IsTransactionValid(txNew, nBlockHeight)) return true; - LogPrint("masternode","Invalid mn payment detected %s\n", txNew.ToString().c_str()); + LogPrint(BCLog::MASTERNODE,"Invalid mn payment detected %s\n", txNew.ToString().c_str()); if (sporkManager.IsSporkActive(SPORK_8_MASTERNODE_PAYMENT_ENFORCEMENT)) return false; - LogPrint("masternode","Masternode payment enforcement is disabled, accepting block\n"); + LogPrint(BCLog::MASTERNODE,"Masternode payment enforcement is disabled, accepting block\n"); return true; } @@ -357,7 +357,7 @@ void CMasternodePayments::FillBlockPayee(CMutableTransaction& txNew, int64_t nFe if (winningNode) { payee = GetScriptForDestination(winningNode->pubKeyCollateralAddress.GetID()); } else { - LogPrint("masternode","CreateNewBlock: Failed to detect masternode to pay\n"); + LogPrint(BCLog::MASTERNODE,"CreateNewBlock: Failed to detect masternode to pay\n"); hasPayment = false; } } @@ -405,7 +405,7 @@ void CMasternodePayments::FillBlockPayee(CMutableTransaction& txNew, int64_t nFe ExtractDestination(payee, address1); CBitcoinAddress address2(address1); - LogPrint("masternode","Masternode payment of %s to %s\n", FormatMoney(masternodePayment).c_str(), address2.ToString().c_str()); + LogPrint(BCLog::MASTERNODE,"Masternode payment of %s to %s\n", FormatMoney(masternodePayment).c_str(), address2.ToString().c_str()); } } @@ -437,7 +437,7 @@ void CMasternodePayments::ProcessMessageMasternodePayments(CNode* pfrom, std::st pfrom->FulfilledRequest("mnget"); masternodePayments.Sync(pfrom, nCountNeeded); - LogPrint("mnpayments", "mnget - Sent Masternode winners to peer %i\n", pfrom->GetId()); + LogPrint(BCLog::MASTERNODE, "mnget - Sent Masternode winners to peer %i\n", pfrom->GetId()); } else if (strCommand == "mnw") { //Masternode Payments Declare Winner //this is required in litemodef CMasternodePaymentWinner winner; @@ -453,14 +453,14 @@ void CMasternodePayments::ProcessMessageMasternodePayments(CNode* pfrom, std::st } if (masternodePayments.mapMasternodePayeeVotes.count(winner.GetHash())) { - LogPrint("mnpayments", "mnw - Already seen - %s bestHeight %d\n", winner.GetHash().ToString().c_str(), nHeight); + LogPrint(BCLog::MASTERNODE, "mnw - Already seen - %s bestHeight %d\n", winner.GetHash().ToString().c_str(), nHeight); masternodeSync.AddedMasternodeWinner(winner.GetHash()); return; } int nFirstBlock = nHeight - (mnodeman.CountEnabled() * 1.25); if (winner.nBlockHeight < nFirstBlock || winner.nBlockHeight > nHeight + 20) { - LogPrint("mnpayments", "mnw - winner out of range - FirstBlock %d Height %d bestHeight %d\n", nFirstBlock, winner.nBlockHeight, nHeight); + LogPrint(BCLog::MASTERNODE, "mnw - winner out of range - FirstBlock %d Height %d bestHeight %d\n", nFirstBlock, winner.nBlockHeight, nHeight); return; } @@ -472,12 +472,12 @@ void CMasternodePayments::ProcessMessageMasternodePayments(CNode* pfrom, std::st std::string strError = ""; if (!winner.IsValid(pfrom, strError)) { - // if(strError != "") LogPrint("masternode","mnw - invalid message - %s\n", strError); + // if(strError != "") LogPrint(BCLog::MASTERNODE,"mnw - invalid message - %s\n", strError); return; } if (!masternodePayments.CanVote(winner.vinMasternode.prevout, winner.nBlockHeight)) { - // LogPrint("masternode","mnw - masternode already voted - %s\n", winner.vinMasternode.prevout.ToStringShort()); + // LogPrint(BCLog::MASTERNODE,"mnw - masternode already voted - %s\n", winner.vinMasternode.prevout.ToStringShort()); return; } @@ -495,7 +495,7 @@ void CMasternodePayments::ProcessMessageMasternodePayments(CNode* pfrom, std::st ExtractDestination(winner.payee, address1); CBitcoinAddress address2(address1); - // LogPrint("mnpayments", "mnw - winning vote - Addr %s Height %d bestHeight %d - %s\n", address2.ToString().c_str(), winner.nBlockHeight, nHeight, winner.vinMasternode.prevout.ToStringShort()); + // LogPrint(BCLog::MASTERNODE, "mnw - winning vote - Addr %s Height %d bestHeight %d - %s\n", address2.ToString().c_str(), winner.nBlockHeight, nHeight, winner.vinMasternode.prevout.ToStringShort()); if (masternodePayments.AddWinningMasternode(winner)) { winner.Relay(); @@ -631,7 +631,7 @@ bool CMasternodeBlockPayees::IsTransactionValid(const CTransaction& txNew) } } - LogPrint("masternode","CMasternodePayments::IsTransactionValid - Missing required payment of %s to %s\n", FormatMoney(requiredMasternodePayment).c_str(), strPayeesPossible.c_str()); + LogPrint(BCLog::MASTERNODE,"CMasternodePayments::IsTransactionValid - Missing required payment of %s to %s\n", FormatMoney(requiredMasternodePayment).c_str(), strPayeesPossible.c_str()); return false; } @@ -697,7 +697,7 @@ void CMasternodePayments::CleanPaymentList() CMasternodePaymentWinner winner = (*it).second; if (nHeight - winner.nBlockHeight > nLimit) { - LogPrint("mnpayments", "CMasternodePayments::CleanPaymentList - Removing old Masternode payment - block %d\n", winner.nBlockHeight); + LogPrint(BCLog::MASTERNODE, "CMasternodePayments::CleanPaymentList - Removing old Masternode payment - block %d\n", winner.nBlockHeight); masternodeSync.mapSeenSyncMNW.erase((*it).first); mapMasternodePayeeVotes.erase(it++); mapMasternodeBlocks.erase(winner.nBlockHeight); @@ -716,12 +716,12 @@ bool CMasternodePayments::ProcessBlock(int nBlockHeight) int n = mnodeman.GetMasternodeRank(activeMasternode.vin, nBlockHeight - 100, ActiveProtocol()); if (n == -1) { - LogPrint("mnpayments", "CMasternodePayments::ProcessBlock - Unknown Masternode\n"); + LogPrint(BCLog::MASTERNODE, "CMasternodePayments::ProcessBlock - Unknown Masternode\n"); return false; } if (n > MNPAYMENTS_SIGNATURES_TOTAL) { - LogPrint("mnpayments", "CMasternodePayments::ProcessBlock - Masternode not in the top %d (%d)\n", MNPAYMENTS_SIGNATURES_TOTAL, n); + LogPrint(BCLog::MASTERNODE, "CMasternodePayments::ProcessBlock - Masternode not in the top %d (%d)\n", MNPAYMENTS_SIGNATURES_TOTAL, n); return false; } @@ -732,14 +732,14 @@ bool CMasternodePayments::ProcessBlock(int nBlockHeight) if (budget.IsBudgetPaymentBlock(nBlockHeight)) { //is budget payment block -- handled by the budgeting software } else { - LogPrint("masternode","CMasternodePayments::ProcessBlock() Start nHeight %d - vin %s. \n", nBlockHeight, activeMasternode.vin.prevout.hash.ToString()); + LogPrint(BCLog::MASTERNODE,"CMasternodePayments::ProcessBlock() Start nHeight %d - vin %s. \n", nBlockHeight, activeMasternode.vin.prevout.hash.ToString()); // pay to the oldest MN that still had no payment but its input is old enough and it was active long enough int nCount = 0; CMasternode* pmn = mnodeman.GetNextMasternodeInQueueForPayment(nBlockHeight, true, nCount); if (pmn != NULL) { - LogPrint("masternode","CMasternodePayments::ProcessBlock() Found by FindOldestNotInVec \n"); + LogPrint(BCLog::MASTERNODE,"CMasternodePayments::ProcessBlock() Found by FindOldestNotInVec \n"); newWinner.nBlockHeight = nBlockHeight; @@ -750,9 +750,9 @@ bool CMasternodePayments::ProcessBlock(int nBlockHeight) ExtractDestination(payee, address1); CBitcoinAddress address2(address1); - LogPrint("masternode","CMasternodePayments::ProcessBlock() Winner payee %s nHeight %d. \n", address2.ToString().c_str(), newWinner.nBlockHeight); + LogPrint(BCLog::MASTERNODE,"CMasternodePayments::ProcessBlock() Winner payee %s nHeight %d. \n", address2.ToString().c_str(), newWinner.nBlockHeight); } else { - LogPrint("masternode","CMasternodePayments::ProcessBlock() Failed to find masternode to pay\n"); + LogPrint(BCLog::MASTERNODE,"CMasternodePayments::ProcessBlock() Failed to find masternode to pay\n"); } } @@ -761,15 +761,15 @@ bool CMasternodePayments::ProcessBlock(int nBlockHeight) CKey keyMasternode; if (!CMessageSigner::GetKeysFromSecret(strMasterNodePrivKey, keyMasternode, pubKeyMasternode)) { - LogPrint("masternode","CMasternodePayments::ProcessBlock() - Error upon calling GetKeysFromSecret.\n"); + LogPrint(BCLog::MASTERNODE,"CMasternodePayments::ProcessBlock() - Error upon calling GetKeysFromSecret.\n"); return false; } const bool fNewSigs = Params().GetConsensus().IsMessSigV2(nBlockHeight - 20); - LogPrint("masternode","CMasternodePayments::ProcessBlock() - Signing Winner\n"); + LogPrint(BCLog::MASTERNODE,"CMasternodePayments::ProcessBlock() - Signing Winner\n"); if (newWinner.Sign(keyMasternode, pubKeyMasternode, fNewSigs)) { - LogPrint("masternode","CMasternodePayments::ProcessBlock() - AddWinningMasternode\n"); + LogPrint(BCLog::MASTERNODE,"CMasternodePayments::ProcessBlock() - AddWinningMasternode\n"); if (AddWinningMasternode(newWinner)) { newWinner.Relay(); diff --git a/src/masternode-sync.cpp b/src/masternode-sync.cpp index 340e85f637de08..58241c7f653dba 100644 --- a/src/masternode-sync.cpp +++ b/src/masternode-sync.cpp @@ -235,7 +235,7 @@ void CMasternodeSync::ProcessMessage(CNode* pfrom, std::string& strCommand, CDat break; } - LogPrint("masternode", "CMasternodeSync:ProcessMessage - ssc - got inventory count %d %d\n", nItemID, nCount); + LogPrint(BCLog::MASTERNODE, "CMasternodeSync:ProcessMessage - ssc - got inventory count %d %d\n", nItemID, nCount); } } @@ -276,7 +276,7 @@ void CMasternodeSync::Process() return; } - LogPrint("masternode", "CMasternodeSync::Process() - tick %d RequestedMasternodeAssets %d\n", tick, RequestedMasternodeAssets); + LogPrint(BCLog::MASTERNODE, "CMasternodeSync::Process() - tick %d RequestedMasternodeAssets %d\n", tick, RequestedMasternodeAssets); if (RequestedMasternodeAssets == MASTERNODE_SYNC_INITIAL) GetNextAsset(); @@ -319,7 +319,7 @@ void CMasternodeSync::Process() if (pnode->nVersion >= masternodePayments.GetMinMasternodePaymentsProto()) { if (RequestedMasternodeAssets == MASTERNODE_SYNC_LIST) { - LogPrint("masternode", "CMasternodeSync::Process() - lastMasternodeList %lld (GetTime() - MASTERNODE_SYNC_TIMEOUT) %lld\n", lastMasternodeList, GetTime() - MASTERNODE_SYNC_TIMEOUT); + LogPrint(BCLog::MASTERNODE, "CMasternodeSync::Process() - lastMasternodeList %lld (GetTime() - MASTERNODE_SYNC_TIMEOUT) %lld\n", lastMasternodeList, GetTime() - MASTERNODE_SYNC_TIMEOUT); if (lastMasternodeList > 0 && lastMasternodeList < GetTime() - MASTERNODE_SYNC_TIMEOUT * 2 && RequestedMasternodeAttempt >= MASTERNODE_SYNC_THRESHOLD) { //hasn't received a new item in the last five seconds, so we'll move to the GetNextAsset(); return; diff --git a/src/masternode.cpp b/src/masternode.cpp index 551dbe8b0862df..08c28220b75d5d 100644 --- a/src/masternode.cpp +++ b/src/masternode.cpp @@ -160,7 +160,7 @@ uint256 CMasternode::CalculateScore(int mod, int64_t nBlockHeight) uint256 aux = vin.prevout.hash + vin.prevout.n; if (!GetBlockHash(hash, nBlockHeight)) { - LogPrint("masternode","CalculateScore ERROR - nHeight %d - Returned 0\n", nBlockHeight); + LogPrint(BCLog::MASTERNODE,"CalculateScore ERROR - nHeight %d - Returned 0\n", nBlockHeight); return UINT256_ZERO; } @@ -369,19 +369,19 @@ bool CMasternodeBroadcast::Create(std::string strService, std::string strKeyMast //need correct blocks to send ping if (!fOffline && !masternodeSync.IsBlockchainSynced()) { strErrorRet = "Sync in progress. Must wait until sync is complete to start Masternode"; - LogPrint("masternode","CMasternodeBroadcast::Create -- %s\n", strErrorRet); + LogPrint(BCLog::MASTERNODE,"CMasternodeBroadcast::Create -- %s\n", strErrorRet); return false; } if (!CMessageSigner::GetKeysFromSecret(strKeyMasternode, keyMasternodeNew, pubKeyMasternodeNew)) { strErrorRet = strprintf("Invalid masternode key %s", strKeyMasternode); - LogPrint("masternode","CMasternodeBroadcast::Create -- %s\n", strErrorRet); + LogPrint(BCLog::MASTERNODE,"CMasternodeBroadcast::Create -- %s\n", strErrorRet); return false; } if (!pwalletMain->GetMasternodeVinAndKeys(txin, pubKeyCollateralAddressNew, keyCollateralAddressNew, strTxHash, strOutputIndex)) { strErrorRet = strprintf("Could not allocate txin %s:%s for masternode %s", strTxHash, strOutputIndex, strService); - LogPrint("masternode","CMasternodeBroadcast::Create -- %s\n", strErrorRet); + LogPrint(BCLog::MASTERNODE,"CMasternodeBroadcast::Create -- %s\n", strErrorRet); return false; } @@ -403,14 +403,14 @@ bool CMasternodeBroadcast::Create(CTxIn txin, CService service, CKey keyCollater fNewSigs = chainActive.NewSigsActive(); } - LogPrint("masternode", "CMasternodeBroadcast::Create -- pubKeyCollateralAddressNew = %s, pubKeyMasternodeNew.GetID() = %s\n", + LogPrint(BCLog::MASTERNODE, "CMasternodeBroadcast::Create -- pubKeyCollateralAddressNew = %s, pubKeyMasternodeNew.GetID() = %s\n", CBitcoinAddress(pubKeyCollateralAddressNew.GetID()).ToString(), pubKeyMasternodeNew.GetID().ToString()); CMasternodePing mnp(txin); if (!mnp.Sign(keyMasternodeNew, pubKeyMasternodeNew, fNewSigs)) { strErrorRet = strprintf("Failed to sign ping, masternode=%s", txin.prevout.hash.ToString()); - LogPrint("masternode","CMasternodeBroadcast::Create -- %s\n", strErrorRet); + LogPrint(BCLog::MASTERNODE,"CMasternodeBroadcast::Create -- %s\n", strErrorRet); mnbRet = CMasternodeBroadcast(); return false; } @@ -419,7 +419,7 @@ bool CMasternodeBroadcast::Create(CTxIn txin, CService service, CKey keyCollater if (!mnbRet.IsValidNetAddr()) { strErrorRet = strprintf("Invalid IP address %s, masternode=%s", mnbRet.addr.ToStringIP (), txin.prevout.hash.ToString()); - LogPrint("masternode","CMasternodeBroadcast::Create -- %s\n", strErrorRet); + LogPrint(BCLog::MASTERNODE,"CMasternodeBroadcast::Create -- %s\n", strErrorRet); mnbRet = CMasternodeBroadcast(); return false; } @@ -427,7 +427,7 @@ bool CMasternodeBroadcast::Create(CTxIn txin, CService service, CKey keyCollater mnbRet.lastPing = mnp; if (!mnbRet.Sign(keyCollateralAddressNew, pubKeyCollateralAddressNew, fNewSigs)) { strErrorRet = strprintf("Failed to sign broadcast, masternode=%s", txin.prevout.hash.ToString()); - LogPrint("masternode","CMasternodeBroadcast::Create -- %s\n", strErrorRet); + LogPrint(BCLog::MASTERNODE,"CMasternodeBroadcast::Create -- %s\n", strErrorRet); mnbRet = CMasternodeBroadcast(); return false; } @@ -495,7 +495,7 @@ bool CMasternodeBroadcast::CheckDefaultPort(std::string strService, std::string& if (service.GetPort() != nDefaultPort) { strErrorRet = strprintf("Invalid port %u for masternode %s, only %d is supported on %s-net.", service.GetPort(), strService, nDefaultPort, Params().NetworkIDString()); - LogPrint("masternode", "%s - %s\n", strContext, strErrorRet); + LogPrint(BCLog::MASTERNODE, "%s - %s\n", strContext, strErrorRet); return false; } @@ -506,7 +506,7 @@ bool CMasternodeBroadcast::CheckAndUpdate(int& nDos) { // make sure signature isn't in the future (past is OK) if (sigTime > GetAdjustedTime() + 60 * 60) { - LogPrint("masternode","mnb - Signature rejected, too far into the future %s\n", vin.prevout.hash.ToString()); + LogPrint(BCLog::MASTERNODE,"mnb - Signature rejected, too far into the future %s\n", vin.prevout.hash.ToString()); nDos = 1; return false; } @@ -516,7 +516,7 @@ bool CMasternodeBroadcast::CheckAndUpdate(int& nDos) return false; if (protocolVersion < masternodePayments.GetMinMasternodePaymentsProto()) { - LogPrint("masternode","mnb - ignoring outdated Masternode %s protocol version %d\n", vin.prevout.hash.ToString(), protocolVersion); + LogPrint(BCLog::MASTERNODE,"mnb - ignoring outdated Masternode %s protocol version %d\n", vin.prevout.hash.ToString(), protocolVersion); return false; } @@ -524,7 +524,7 @@ bool CMasternodeBroadcast::CheckAndUpdate(int& nDos) pubkeyScript = GetScriptForDestination(pubKeyCollateralAddress.GetID()); if (pubkeyScript.size() != 25) { - LogPrint("masternode","mnb - pubkey the wrong size\n"); + LogPrint(BCLog::MASTERNODE,"mnb - pubkey the wrong size\n"); nDos = 100; return false; } @@ -533,13 +533,13 @@ bool CMasternodeBroadcast::CheckAndUpdate(int& nDos) pubkeyScript2 = GetScriptForDestination(pubKeyMasternode.GetID()); if (pubkeyScript2.size() != 25) { - LogPrint("masternode","mnb - pubkey2 the wrong size\n"); + LogPrint(BCLog::MASTERNODE,"mnb - pubkey2 the wrong size\n"); nDos = 100; return false; } if (!vin.scriptSig.empty()) { - LogPrint("masternode","mnb - Ignore Not Empty ScriptSig %s\n", vin.prevout.hash.ToString()); + LogPrint(BCLog::MASTERNODE,"mnb - Ignore Not Empty ScriptSig %s\n", vin.prevout.hash.ToString()); return false; } @@ -577,7 +577,7 @@ bool CMasternodeBroadcast::CheckAndUpdate(int& nDos) // after that they just need to match if (pmn->pubKeyCollateralAddress == pubKeyCollateralAddress && !pmn->IsBroadcastedWithin(MASTERNODE_MIN_MNB_SECONDS)) { //take the newest entry - LogPrint("masternode","mnb - Got updated entry for %s\n", vin.prevout.hash.ToString()); + LogPrint(BCLog::MASTERNODE,"mnb - Got updated entry for %s\n", vin.prevout.hash.ToString()); if (pmn->UpdateFromNewBroadcast((*this))) { pmn->Check(); if (pmn->IsEnabled()) Relay(); @@ -631,10 +631,10 @@ bool CMasternodeBroadcast::CheckInputsAndAdd(int& nDoS) } } - LogPrint("masternode", "mnb - Accepted Masternode entry\n"); + LogPrint(BCLog::MASTERNODE, "mnb - Accepted Masternode entry\n"); if (GetInputAge(vin) < MASTERNODE_MIN_CONFIRMATIONS) { - LogPrint("masternode","mnb - Input must have at least %d confirmations\n", MASTERNODE_MIN_CONFIRMATIONS); + LogPrint(BCLog::MASTERNODE,"mnb - Input must have at least %d confirmations\n", MASTERNODE_MIN_CONFIRMATIONS); // maybe we miss few blocks, let this mnb to be checked again later mnodeman.mapSeenMasternodeBroadcast.erase(GetHash()); masternodeSync.mapSeenSyncMNB.erase(GetHash()); @@ -651,13 +651,13 @@ bool CMasternodeBroadcast::CheckInputsAndAdd(int& nDoS) CBlockIndex* pMNIndex = (*mi).second; // block for 1000 PIVX tx -> 1 confirmation CBlockIndex* pConfIndex = chainActive[pMNIndex->nHeight + MASTERNODE_MIN_CONFIRMATIONS - 1]; // block where tx got MASTERNODE_MIN_CONFIRMATIONS if (pConfIndex->GetBlockTime() > sigTime) { - LogPrint("masternode","mnb - Bad sigTime %d for Masternode %s (%i conf block is at %d)\n", + LogPrint(BCLog::MASTERNODE,"mnb - Bad sigTime %d for Masternode %s (%i conf block is at %d)\n", sigTime, vin.prevout.hash.ToString(), MASTERNODE_MIN_CONFIRMATIONS, pConfIndex->GetBlockTime()); return false; } } - LogPrint("masternode","mnb - Got NEW Masternode entry - %s - %lli \n", vin.prevout.hash.ToString(), sigTime); + LogPrint(BCLog::MASTERNODE,"mnb - Got NEW Masternode entry - %s - %lli \n", vin.prevout.hash.ToString(), sigTime); CMasternode mn(*this); mnodeman.Add(mn); @@ -725,13 +725,13 @@ std::string CMasternodePing::GetStrMessage() const bool CMasternodePing::CheckAndUpdate(int& nDos, bool fRequireEnabled, bool fCheckSigTimeOnly) { if (sigTime > GetAdjustedTime() + 60 * 60) { - LogPrint("masternode","CMasternodePing::CheckAndUpdate - Signature rejected, too far into the future %s\n", vin.prevout.hash.ToString()); + LogPrint(BCLog::MASTERNODE,"CMasternodePing::CheckAndUpdate - Signature rejected, too far into the future %s\n", vin.prevout.hash.ToString()); nDos = 1; return false; } if (sigTime <= GetAdjustedTime() - 60 * 60) { - LogPrint("masternode","CMasternodePing::CheckAndUpdate - Signature rejected, too far into the past %s - %d %d \n", vin.prevout.hash.ToString(), sigTime, GetAdjustedTime()); + LogPrint(BCLog::MASTERNODE,"CMasternodePing::CheckAndUpdate - Signature rejected, too far into the past %s - %d %d \n", vin.prevout.hash.ToString(), sigTime, GetAdjustedTime()); nDos = 1; return false; } @@ -749,12 +749,12 @@ bool CMasternodePing::CheckAndUpdate(int& nDos, bool fRequireEnabled, bool fChec return true; } - LogPrint("masternode", "CMasternodePing::CheckAndUpdate - New Ping - %s - %s - %lli\n", GetHash().ToString(), blockHash.ToString(), sigTime); + LogPrint(BCLog::MASTERNODE, "CMasternodePing::CheckAndUpdate - New Ping - %s - %s - %lli\n", GetHash().ToString(), blockHash.ToString(), sigTime); if (isMasternodeFound && pmn->protocolVersion >= masternodePayments.GetMinMasternodePaymentsProto()) { if (fRequireEnabled && !pmn->IsEnabled()) return false; - // LogPrint("masternode","mnping - Found corresponding mn for vin: %s\n", vin.ToString()); + // LogPrint(BCLog::MASTERNODE,"mnping - Found corresponding mn for vin: %s\n", vin.ToString()); // update only if there is no known ping for this masternode or // last ping was more then MASTERNODE_MIN_MNP_SECONDS-60 ago comparing to this one if (!pmn->IsPingedWithin(MASTERNODE_MIN_MNP_SECONDS - 60, sigTime)) { @@ -766,14 +766,14 @@ bool CMasternodePing::CheckAndUpdate(int& nDos, bool fRequireEnabled, bool fChec BlockMap::iterator mi = mapBlockIndex.find(blockHash); if (mi != mapBlockIndex.end() && (*mi).second) { if ((*mi).second->nHeight < chainActive.Height() - 24) { - LogPrint("masternode","CMasternodePing::CheckAndUpdate - Masternode %s block hash %s is too old\n", vin.prevout.hash.ToString(), blockHash.ToString()); + LogPrint(BCLog::MASTERNODE,"CMasternodePing::CheckAndUpdate - Masternode %s block hash %s is too old\n", vin.prevout.hash.ToString(), blockHash.ToString()); // Do nothing here (no Masternode update, no mnping relay) // Let this node to be visible but fail to accept mnping return false; } } else { - if (fDebug) LogPrint("masternode","CMasternodePing::CheckAndUpdate - Masternode %s block hash %s is unknown\n", vin.prevout.hash.ToString(), blockHash.ToString()); + LogPrint(BCLog::MASTERNODE,"CMasternodePing::CheckAndUpdate - Masternode %s block hash %s is unknown\n", vin.prevout.hash.ToString(), blockHash.ToString()); // maybe we stuck so we shouldn't ban this node, just fail to accept it // TODO: or should we also request this block? @@ -792,16 +792,16 @@ bool CMasternodePing::CheckAndUpdate(int& nDos, bool fRequireEnabled, bool fChec pmn->Check(true); if (!pmn->IsEnabled()) return false; - LogPrint("masternode", "CMasternodePing::CheckAndUpdate - Masternode ping accepted, vin: %s\n", vin.prevout.hash.ToString()); + LogPrint(BCLog::MASTERNODE, "CMasternodePing::CheckAndUpdate - Masternode ping accepted, vin: %s\n", vin.prevout.hash.ToString()); Relay(); return true; } - LogPrint("masternode", "CMasternodePing::CheckAndUpdate - Masternode ping arrived too early, vin: %s\n", vin.prevout.hash.ToString()); + LogPrint(BCLog::MASTERNODE, "CMasternodePing::CheckAndUpdate - Masternode ping arrived too early, vin: %s\n", vin.prevout.hash.ToString()); //nDos = 1; //disable, this is happening frequently and causing banned peers return false; } - LogPrint("masternode", "CMasternodePing::CheckAndUpdate - Couldn't find compatible Masternode entry, vin: %s\n", vin.prevout.hash.ToString()); + LogPrint(BCLog::MASTERNODE, "CMasternodePing::CheckAndUpdate - Couldn't find compatible Masternode entry, vin: %s\n", vin.prevout.hash.ToString()); return false; } diff --git a/src/masternodeman.cpp b/src/masternodeman.cpp index 48cf6bad2589ad..9310abad5be6c7 100644 --- a/src/masternodeman.cpp +++ b/src/masternodeman.cpp @@ -79,8 +79,8 @@ bool CMasternodeDB::Write(const CMasternodeMan& mnodemanToSave) // FileCommit(fileout); fileout.fclose(); - LogPrint("masternode","Written info to mncache.dat %dms\n", GetTimeMillis() - nStart); - LogPrint("masternode"," %s\n", mnodemanToSave.ToString()); + LogPrint(BCLog::MASTERNODE,"Written info to mncache.dat %dms\n", GetTimeMillis() - nStart); + LogPrint(BCLog::MASTERNODE," %s\n", mnodemanToSave.ToString()); return true; } @@ -154,13 +154,13 @@ CMasternodeDB::ReadResult CMasternodeDB::Read(CMasternodeMan& mnodemanToLoad, bo return IncorrectFormat; } - LogPrint("masternode","Loaded info from mncache.dat %dms\n", GetTimeMillis() - nStart); - LogPrint("masternode"," %s\n", mnodemanToLoad.ToString()); + LogPrint(BCLog::MASTERNODE,"Loaded info from mncache.dat %dms\n", GetTimeMillis() - nStart); + LogPrint(BCLog::MASTERNODE," %s\n", mnodemanToLoad.ToString()); if (!fDryRun) { - LogPrint("masternode","Masternode manager - cleaning....\n"); + LogPrint(BCLog::MASTERNODE,"Masternode manager - cleaning....\n"); mnodemanToLoad.CheckAndRemove(true); - LogPrint("masternode","Masternode manager - result:\n"); - LogPrint("masternode"," %s\n", mnodemanToLoad.ToString()); + LogPrint(BCLog::MASTERNODE,"Masternode manager - result:\n"); + LogPrint(BCLog::MASTERNODE," %s\n", mnodemanToLoad.ToString()); } return Ok; @@ -173,24 +173,24 @@ void DumpMasternodes() CMasternodeDB mndb; CMasternodeMan tempMnodeman; - LogPrint("masternode","Verifying mncache.dat format...\n"); + LogPrint(BCLog::MASTERNODE,"Verifying mncache.dat format...\n"); CMasternodeDB::ReadResult readResult = mndb.Read(tempMnodeman, true); // there was an error and it was not an error on file opening => do not proceed if (readResult == CMasternodeDB::FileError) - LogPrint("masternode","Missing masternode cache file - mncache.dat, will try to recreate\n"); + LogPrint(BCLog::MASTERNODE,"Missing masternode cache file - mncache.dat, will try to recreate\n"); else if (readResult != CMasternodeDB::Ok) { - LogPrint("masternode","Error reading mncache.dat: "); + LogPrint(BCLog::MASTERNODE,"Error reading mncache.dat: "); if (readResult == CMasternodeDB::IncorrectFormat) - LogPrint("masternode","magic is ok but data has invalid format, will try to recreate\n"); + LogPrint(BCLog::MASTERNODE,"magic is ok but data has invalid format, will try to recreate\n"); else { - LogPrint("masternode","file format is unknown or invalid, please fix it manually\n"); + LogPrint(BCLog::MASTERNODE,"file format is unknown or invalid, please fix it manually\n"); return; } } - LogPrint("masternode","Writting info to mncache.dat...\n"); + LogPrint(BCLog::MASTERNODE,"Writting info to mncache.dat...\n"); mndb.Write(mnodeman); - LogPrint("masternode","Masternode dump finished %dms\n", GetTimeMillis() - nStart); + LogPrint(BCLog::MASTERNODE,"Masternode dump finished %dms\n", GetTimeMillis() - nStart); } CMasternodeMan::CMasternodeMan() @@ -207,7 +207,7 @@ bool CMasternodeMan::Add(CMasternode& mn) CMasternode* pmn = Find(mn.vin); if (pmn == NULL) { - LogPrint("masternode", "CMasternodeMan: Adding new Masternode %s - %i now\n", mn.vin.prevout.hash.ToString(), size() + 1); + LogPrint(BCLog::MASTERNODE, "CMasternodeMan: Adding new Masternode %s - %i now\n", mn.vin.prevout.hash.ToString(), size() + 1); vMasternodes.push_back(mn); return true; } @@ -225,7 +225,7 @@ void CMasternodeMan::AskForMN(CNode* pnode, CTxIn& vin) // ask for the mnb info once from the node that sent mnp - LogPrint("masternode", "CMasternodeMan::AskForMN - Asking node for missing entry, vin: %s\n", vin.prevout.hash.ToString()); + LogPrint(BCLog::MASTERNODE, "CMasternodeMan::AskForMN - Asking node for missing entry, vin: %s\n", vin.prevout.hash.ToString()); pnode->PushMessage("dseg", vin); int64_t askAgain = GetTime() + MASTERNODE_MIN_MNP_SECONDS; mWeAskedForMasternodeListEntry[vin.prevout] = askAgain; @@ -253,7 +253,7 @@ void CMasternodeMan::CheckAndRemove(bool forceExpiredRemoval) (*it).activeState == CMasternode::MASTERNODE_VIN_SPENT || (forceExpiredRemoval && (*it).activeState == CMasternode::MASTERNODE_EXPIRED) || (*it).protocolVersion < masternodePayments.GetMinMasternodePaymentsProto()) { - LogPrint("masternode", "CMasternodeMan: Removing inactive Masternode %s - %i now\n", (*it).vin.prevout.hash.ToString(), size() - 1); + LogPrint(BCLog::MASTERNODE, "CMasternodeMan: Removing inactive Masternode %s - %i now\n", (*it).vin.prevout.hash.ToString(), size() - 1); //erase all of the broadcasts we've seen from this vin // -- if we missed a few pings and the node was removed, this will allow is to get it back without them @@ -423,7 +423,7 @@ void CMasternodeMan::DsegUpdate(CNode* pnode) std::map::iterator it = mWeAskedForMasternodeList.find(pnode->addr); if (it != mWeAskedForMasternodeList.end()) { if (GetTime() < (*it).second) { - LogPrint("masternode", "dseg - we already asked peer %i for the list; skipping...\n", pnode->GetId()); + LogPrint(BCLog::MASTERNODE, "dseg - we already asked peer %i for the list; skipping...\n", pnode->GetId()); return; } } @@ -542,11 +542,11 @@ CMasternode* CMasternodeMan::FindRandomNotInVec(std::vector& vecToExclude protocolVersion = protocolVersion == -1 ? masternodePayments.GetMinMasternodePaymentsProto() : protocolVersion; int nCountEnabled = CountEnabled(protocolVersion); - LogPrint("masternode", "CMasternodeMan::FindRandomNotInVec - nCountEnabled - vecToExclude.size() %d\n", nCountEnabled - vecToExclude.size()); + LogPrint(BCLog::MASTERNODE, "CMasternodeMan::FindRandomNotInVec - nCountEnabled - vecToExclude.size() %d\n", nCountEnabled - vecToExclude.size()); if (nCountEnabled - vecToExclude.size() < 1) return NULL; int rand = GetRandInt(nCountEnabled - vecToExclude.size()); - LogPrint("masternode", "CMasternodeMan::FindRandomNotInVec - rand %d\n", rand); + LogPrint(BCLog::MASTERNODE, "CMasternodeMan::FindRandomNotInVec - rand %d\n", rand); bool found; for (CMasternode& mn : vMasternodes) { @@ -604,14 +604,14 @@ int CMasternodeMan::GetMasternodeRank(const CTxIn& vin, int64_t nBlockHeight, in // scan for winner for (CMasternode& mn : vMasternodes) { if (mn.protocolVersion < minProtocol) { - LogPrint("masternode","Skipping Masternode with obsolete version %d\n", mn.protocolVersion); + LogPrint(BCLog::MASTERNODE,"Skipping Masternode with obsolete version %d\n", mn.protocolVersion); continue; // Skip obsolete versions } if (sporkManager.IsSporkActive(SPORK_8_MASTERNODE_PAYMENT_ENFORCEMENT)) { nMasternode_Age = GetAdjustedTime() - mn.sigTime; if ((nMasternode_Age) < nMasternode_Min_Age) { - if (fDebug) LogPrint("masternode","Skipping just activated Masternode. Age: %ld\n", nMasternode_Age); + LogPrint(BCLog::MASTERNODE,"Skipping just activated Masternode. Age: %ld\n", nMasternode_Age); continue; // Skip masternodes younger than (default) 1 hour } } @@ -715,7 +715,7 @@ void CMasternodeMan::ProcessMasternodeConnections() for (CNode* pnode : vNodes) { if (pnode->fObfuScationMaster) { if (obfuScationPool.pSubmittedToMasternode != NULL && pnode->addr == obfuScationPool.pSubmittedToMasternode->addr) continue; - LogPrint("masternode","Closing Masternode connection peer=%i \n", pnode->GetId()); + LogPrint(BCLog::MASTERNODE,"Closing Masternode connection peer=%i \n", pnode->GetId()); pnode->fObfuScationMaster = false; pnode->Release(); } @@ -763,7 +763,7 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData addrman.Add(CAddress(mnb.addr), pfrom->addr, 2 * 60 * 60); masternodeSync.AddedMasternodeList(mnb.GetHash()); } else { - LogPrint("masternode","mnb - Rejected Masternode entry %s\n", mnb.vin.prevout.hash.ToString()); + LogPrint(BCLog::MASTERNODE,"mnb - Rejected Masternode entry %s\n", mnb.vin.prevout.hash.ToString()); if (nDoS > 0) Misbehaving(pfrom->GetId(), nDoS); @@ -774,7 +774,7 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData CMasternodePing mnp; vRecv >> mnp; - LogPrint("masternode", "mnp - Masternode ping, vin: %s\n", mnp.vin.prevout.hash.ToString()); + LogPrint(BCLog::MASTERNODE, "mnp - Masternode ping, vin: %s\n", mnp.vin.prevout.hash.ToString()); if (mapSeenMasternodePing.count(mnp.GetHash())) return; //seen mapSeenMasternodePing.insert(std::make_pair(mnp.GetHash(), mnp)); @@ -827,7 +827,7 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData if (mn.addr.IsRFC1918()) continue; //local network if (mn.IsEnabled()) { - LogPrint("masternode", "dseg - Sending Masternode entry - %s \n", mn.vin.prevout.hash.ToString()); + LogPrint(BCLog::MASTERNODE, "dseg - Sending Masternode entry - %s \n", mn.vin.prevout.hash.ToString()); if (vin == CTxIn() || vin == mn.vin) { CMasternodeBroadcast mnb = CMasternodeBroadcast(mn); uint256 hash = mnb.GetHash(); @@ -837,7 +837,7 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData if (!mapSeenMasternodeBroadcast.count(hash)) mapSeenMasternodeBroadcast.insert(std::make_pair(hash, mnb)); if (vin == mn.vin) { - LogPrint("masternode", "dseg - Sent 1 Masternode entry to peer %i\n", pfrom->GetId()); + LogPrint(BCLog::MASTERNODE, "dseg - Sent 1 Masternode entry to peer %i\n", pfrom->GetId()); return; } } @@ -846,7 +846,7 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData if (vin == CTxIn()) { pfrom->PushMessage("ssc", MASTERNODE_SYNC_LIST, nInvCount); - LogPrint("masternode", "dseg - Sent %d Masternode entries to peer %i\n", nInvCount, pfrom->GetId()); + LogPrint(BCLog::MASTERNODE, "dseg - Sent %d Masternode entries to peer %i\n", nInvCount, pfrom->GetId()); } } } @@ -858,7 +858,7 @@ void CMasternodeMan::Remove(CTxIn vin) std::vector::iterator it = vMasternodes.begin(); while (it != vMasternodes.end()) { if ((*it).vin == vin) { - LogPrint("masternode", "CMasternodeMan: Removing Masternode %s - %i now\n", (*it).vin.prevout.hash.ToString(), size() - 1); + LogPrint(BCLog::MASTERNODE, "CMasternodeMan: Removing Masternode %s - %i now\n", (*it).vin.prevout.hash.ToString(), size() - 1); vMasternodes.erase(it); break; } @@ -872,7 +872,7 @@ void CMasternodeMan::UpdateMasternodeList(CMasternodeBroadcast mnb) mapSeenMasternodeBroadcast.insert(std::make_pair(mnb.GetHash(), mnb)); masternodeSync.AddedMasternodeList(mnb.GetHash()); - LogPrint("masternode","CMasternodeMan::UpdateMasternodeList() -- masternode=%s\n", mnb.vin.prevout.ToString()); + LogPrint(BCLog::MASTERNODE,"CMasternodeMan::UpdateMasternodeList() -- masternode=%s\n", mnb.vin.prevout.ToString()); CMasternode* pmn = Find(mnb.vin); if (pmn == NULL) { diff --git a/src/miner.cpp b/src/miner.cpp index 1bc8b19c299ed8..82caaf773f8fdf 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -152,7 +152,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn, CWallet* pwallet, CMutableTransaction txCoinStake; int64_t nTxNewTime = 0; if (!pwallet->CreateCoinStake(*pwallet, pindexPrev, pblock->nBits, txCoinStake, nTxNewTime)) { - LogPrint("staking", "%s : stake not found\n", __func__); + LogPrint(BCLog::STAKING, "%s : stake not found\n", __func__); return nullptr; } // Stake found @@ -218,7 +218,6 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn, CWallet* pwallet, // or other transactions in the memory pool. if (!mempool.mapTx.count(txin.prevout.hash)) { LogPrintf("ERROR: mempool transaction missing input\n"); - if (fDebug) assert("mempool transaction missing input" == 0); fMissingInputs = true; if (porphan) vOrphan.pop_back(); diff --git a/src/net.cpp b/src/net.cpp index bc18b0ee359acf..78fe79104d826b 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -189,12 +189,12 @@ bool RecvLine(SOCKET hSocket, std::string& strLine) return true; if (nBytes == 0) { // socket closed - LogPrint("net", "socket closed\n"); + LogPrint(BCLog::NET, "socket closed\n"); return false; } else { // socket error int nErr = WSAGetLastError(); - LogPrint("net", "recv failed: %s\n", NetworkErrorString(nErr)); + LogPrint(BCLog::NET, "recv failed: %s\n", NetworkErrorString(nErr)); return false; } } @@ -404,7 +404,7 @@ CNode* ConnectNode(CAddress addrConnect, const char* pszDest, bool obfuScationMa } /// debug print - LogPrint("net", "trying connection %s lastseen=%.1fhrs\n", + LogPrint(BCLog::NET, "trying connection %s lastseen=%.1fhrs\n", pszDest ? pszDest : addrConnect.ToString(), pszDest ? 0.0 : (double)(GetAdjustedTime() - addrConnect.nTime) / 3600.0); @@ -447,7 +447,7 @@ void CNode::CloseSocketDisconnect() { fDisconnect = true; if (hSocket != INVALID_SOCKET) { - LogPrint("net", "disconnecting peer=%d\n", id); + LogPrint(BCLog::NET, "disconnecting peer=%d\n", id); CloseSocket(hSocket); } @@ -479,9 +479,9 @@ void CNode::PushVersion() CAddress addrMe = GetLocalAddress(&addr); GetRandBytes((unsigned char*)&nLocalHostNonce, sizeof(nLocalHostNonce)); if (fLogIPs) - LogPrint("net", "send version message: version %d, blocks=%d, us=%s, them=%s, peer=%d\n", PROTOCOL_VERSION, nBestHeight, addrMe.ToString(), addrYou.ToString(), id); + LogPrint(BCLog::NET, "send version message: version %d, blocks=%d, us=%s, them=%s, peer=%d\n", PROTOCOL_VERSION, nBestHeight, addrMe.ToString(), addrYou.ToString(), id); else - LogPrint("net", "send version message: version %d, blocks=%d, us=%s, peer=%d\n", PROTOCOL_VERSION, nBestHeight, addrMe.ToString(), id); + LogPrint(BCLog::NET, "send version message: version %d, blocks=%d, us=%s, peer=%d\n", PROTOCOL_VERSION, nBestHeight, addrMe.ToString(), id); PushMessage("version", PROTOCOL_VERSION, nLocalServices, nTime, addrYou, addrMe, nLocalHostNonce, strSubVersion, nBestHeight, true); } @@ -621,7 +621,7 @@ void CNode::SweepBanned() setBanned.erase(it++); setBannedIsDirty = true; notifyUI = true; - LogPrint("net", "%s: Removed banned node ip/subnet from banlist.dat: %s\n", __func__, subNet.ToString()); + LogPrint(BCLog::NET, "%s: Removed banned node ip/subnet from banlist.dat: %s\n", __func__, subNet.ToString()); } else ++it; @@ -726,7 +726,7 @@ bool CNode::ReceiveMsgBytes(const char* pch, unsigned int nBytes) return false; if (msg.in_data && msg.hdr.nMessageSize > MAX_PROTOCOL_MESSAGE_LENGTH) { - LogPrint("net", "Oversized message from peer=%i, disconnecting", GetId()); + LogPrint(BCLog::NET, "Oversized message from peer=%i, disconnecting", GetId()); return false; } @@ -1042,7 +1042,7 @@ void ThreadSocketHandler() LogPrintf("connection from %s dropped: non-selectable socket\n", addr.ToString()); CloseSocket(hSocket); } else if (nInbound >= nMaxConnections - MAX_OUTBOUND_CONNECTIONS) { - LogPrint("net", "connection from %s dropped (full)\n", addr.ToString()); + LogPrint(BCLog::NET, "connection from %s dropped (full)\n", addr.ToString()); CloseSocket(hSocket); } else if (CNode::IsBanned(addr) && !whitelisted) { LogPrintf("connection from %s dropped (banned)\n", addr.ToString()); @@ -1094,7 +1094,7 @@ void ThreadSocketHandler() } else if (nBytes == 0) { // socket closed gracefully if (!pnode->fDisconnect) - LogPrint("net", "socket closed\n"); + LogPrint(BCLog::NET, "socket closed\n"); pnode->CloseSocketDisconnect(); } else if (nBytes < 0) { // error @@ -1126,7 +1126,7 @@ void ThreadSocketHandler() int64_t nTime = GetTime(); if (nTime - pnode->nTimeConnected > 60) { if (pnode->nLastRecv == 0 || pnode->nLastSend == 0) { - LogPrint("net", "socket no message in first 60 seconds, %d %d from %d\n", pnode->nLastRecv != 0, pnode->nLastSend != 0, pnode->id); + LogPrint(BCLog::NET, "socket no message in first 60 seconds, %d %d from %d\n", pnode->nLastRecv != 0, pnode->nLastSend != 0, pnode->id); pnode->fDisconnect = true; } else if (nTime - pnode->nLastSend > TIMEOUT_INTERVAL) { LogPrintf("socket sending timeout: %is\n", nTime - pnode->nLastSend); @@ -1316,7 +1316,7 @@ void DumpAddresses() CAddrDB adb; adb.Write(addrman); - LogPrint("net", "Flushed %d addresses to peers.dat %dms\n", + LogPrint(BCLog::NET, "Flushed %d addresses to peers.dat %dms\n", addrman.size(), GetTimeMillis() - nStart); } @@ -1755,7 +1755,7 @@ void StartNode(boost::thread_group& threadGroup, CScheduler& scheduler) CNode::SetBannedSetDirty(false); // no need to write down, just read data CNode::SweepBanned(); // sweep out unused entries - LogPrint("net", "Loaded %d banned node ips/subnets from banlist.dat %dms\n", + LogPrint(BCLog::NET, "Loaded %d banned node ips/subnets from banlist.dat %dms\n", banmap.size(), GetTimeMillis() - nStart); } else { LogPrintf("Invalid or missing banlist.dat; recreating\n"); @@ -2133,9 +2133,9 @@ CNode::CNode(SOCKET hSocketIn, CAddress addrIn, std::string addrNameIn, bool fIn } if (fLogIPs) - LogPrint("net", "Added connection to %s peer=%d\n", addrName, id); + LogPrint(BCLog::NET, "Added connection to %s peer=%d\n", addrName, id); else - LogPrint("net", "Added connection peer=%d\n", id); + LogPrint(BCLog::NET, "Added connection peer=%d\n", id); // Be shy and don't send version until we hear if (hSocket != INVALID_SOCKET && !fInbound) @@ -2166,7 +2166,7 @@ void CNode::AskFor(const CInv& inv) nRequestTime = it->second; else nRequestTime = 0; - LogPrint("net", "askfor %s %d (%s) peer=%d\n", inv.ToString(), nRequestTime, DateTimeStrFormat("%H:%M:%S", nRequestTime / 1000000), id); + LogPrint(BCLog::NET, "askfor %s %d (%s) peer=%d\n", inv.ToString(), nRequestTime, DateTimeStrFormat("%H:%M:%S", nRequestTime / 1000000), id); // Make sure not to reuse time indexes to keep things in the same order int64_t nNow = GetTimeMicros() - 1000000; @@ -2189,7 +2189,7 @@ void CNode::BeginMessage(const char* pszCommand) EXCLUSIVE_LOCK_FUNCTION(cs_vSen ENTER_CRITICAL_SECTION(cs_vSend); assert(ssSend.size() == 0); ssSend << CMessageHeader(pszCommand, 0); - LogPrint("net", "sending: %s ", SanitizeString(pszCommand)); + LogPrint(BCLog::NET, "sending: %s ", SanitizeString(pszCommand)); } void CNode::AbortMessage() UNLOCK_FUNCTION(cs_vSend) @@ -2198,7 +2198,7 @@ void CNode::AbortMessage() UNLOCK_FUNCTION(cs_vSend) LEAVE_CRITICAL_SECTION(cs_vSend); - LogPrint("net", "(aborted)\n"); + LogPrint(BCLog::NET, "(aborted)\n"); } void CNode::EndMessage() UNLOCK_FUNCTION(cs_vSend) @@ -2207,7 +2207,7 @@ void CNode::EndMessage() UNLOCK_FUNCTION(cs_vSend) // since they are only used during development to debug the networking code and are // not intended for end-users. if (mapArgs.count("-dropmessagestest") && GetRand(GetArg("-dropmessagestest", 2)) == 0) { - LogPrint("net", "dropmessages DROPPING SEND MESSAGE\n"); + LogPrint(BCLog::NET, "dropmessages DROPPING SEND MESSAGE\n"); AbortMessage(); return; } @@ -2230,7 +2230,7 @@ void CNode::EndMessage() UNLOCK_FUNCTION(cs_vSend) assert(ssSend.size() >= CMessageHeader::CHECKSUM_OFFSET + sizeof(nChecksum)); memcpy((char*)&ssSend[CMessageHeader::CHECKSUM_OFFSET], &nChecksum, sizeof(nChecksum)); - LogPrint("net", "(%d bytes) peer=%d\n", nSize, id); + LogPrint(BCLog::NET, "(%d bytes) peer=%d\n", nSize, id); std::deque::iterator it = vSendMsg.insert(vSendMsg.end(), CSerializeData()); ssSend.GetAndClear(*it); @@ -2359,6 +2359,6 @@ void DumpBanlist() if (bandb.Write(banmap)) CNode::SetBannedSetDirty(false); - LogPrint("net", "Flushed %d banned node ips/subnets to banlist.dat %dms\n", + LogPrint(BCLog::NET, "Flushed %d banned node ips/subnets to banlist.dat %dms\n", banmap.size(), GetTimeMillis() - nStart); } diff --git a/src/netbase.cpp b/src/netbase.cpp index 82ceb75a21ee6f..4435031e0a0ec5 100644 --- a/src/netbase.cpp +++ b/src/netbase.cpp @@ -353,7 +353,7 @@ bool static Socks5(std::string strDest, int port, const ProxyCredentials *auth, CloseSocket(hSocket); return error("Error sending authentication to proxy"); } - LogPrint("proxy", "SOCKS5 sending proxy authentication %s:%s\n", auth->username, auth->password); + LogPrint(BCLog::PROXY, "SOCKS5 sending proxy authentication %s:%s\n", auth->username, auth->password); char pchRetA[2]; if ((recvr = InterruptibleRecv(pchRetA, 2, SOCKS5_RECV_TIMEOUT, hSocket)) != IntrRecvError::OK) { CloseSocket(hSocket); @@ -495,7 +495,7 @@ bool static ConnectSocketDirectly(const CService& addrConnect, SOCKET& hSocketRe FD_SET(hSocket, &fdset); int nRet = select(hSocket + 1, NULL, &fdset, NULL, &timeout); if (nRet == 0) { - LogPrint("net", "connection to %s timeout\n", addrConnect.ToString()); + LogPrint(BCLog::NET, "connection to %s timeout\n", addrConnect.ToString()); CloseSocket(hSocket); return false; } diff --git a/src/obfuscation.cpp b/src/obfuscation.cpp index 549497a4190d28..ad8299818b519a 100644 --- a/src/obfuscation.cpp +++ b/src/obfuscation.cpp @@ -109,22 +109,22 @@ void CObfuscationPool::UnlockCoins() // void CObfuscationPool::Check() { - if (fMasterNode) LogPrint("obfuscation", "CObfuscationPool::Check() - entries count %lu\n", entries.size()); + if (fMasterNode) LogPrint(BCLog::MASTERNODE, "CObfuscationPool::Check() - entries count %lu\n", entries.size()); //printf("CObfuscationPool::Check() %d - %d - %d\n", state, anonTx.CountEntries(), GetTimeMillis()-lastTimeChanged); if (fMasterNode) { - LogPrint("obfuscation", "CObfuscationPool::Check() - entries count %lu\n", entries.size()); + LogPrint(BCLog::MASTERNODE, "CObfuscationPool::Check() - entries count %lu\n", entries.size()); // If entries is full, then move on to the next phase if (state == POOL_STATUS_ACCEPTING_ENTRIES && (int)entries.size() >= GetMaxPoolTransactions()) { - LogPrint("obfuscation", "CObfuscationPool::Check() -- TRYING TRANSACTION \n"); + LogPrint(BCLog::MASTERNODE, "CObfuscationPool::Check() -- TRYING TRANSACTION \n"); UpdateState(POOL_STATUS_FINALIZE_TRANSACTION); } } // create the finalized transaction for distribution to the clients if (state == POOL_STATUS_FINALIZE_TRANSACTION) { - LogPrint("obfuscation", "CObfuscationPool::Check() -- FINALIZE TRANSACTIONS\n"); + LogPrint(BCLog::MASTERNODE, "CObfuscationPool::Check() -- FINALIZE TRANSACTIONS\n"); UpdateState(POOL_STATUS_SIGNING); if (fMasterNode) { @@ -144,7 +144,7 @@ void CObfuscationPool::Check() std::random_shuffle(txNew.vout.begin(), txNew.vout.end(), randomizeList); - LogPrint("obfuscation", "Transaction 1: %s\n", txNew.ToString()); + LogPrint(BCLog::MASTERNODE, "Transaction 1: %s\n", txNew.ToString()); finalTransaction = txNew; // request signatures from clients @@ -154,7 +154,7 @@ void CObfuscationPool::Check() // If we have all of the signatures, try to compile the transaction if (fMasterNode && state == POOL_STATUS_SIGNING && SignaturesComplete()) { - LogPrint("obfuscation", "CObfuscationPool::Check() -- SIGNING\n"); + LogPrint(BCLog::MASTERNODE, "CObfuscationPool::Check() -- SIGNING\n"); UpdateState(POOL_STATUS_TRANSMISSION); CheckFinalTransaction(); @@ -162,7 +162,7 @@ void CObfuscationPool::Check() // reset if we're here for 10 seconds if ((state == POOL_STATUS_ERROR || state == POOL_STATUS_SUCCESS) && GetTimeMillis() - lastTimeChanged >= 10000) { - LogPrint("obfuscation", "CObfuscationPool::Check() -- timeout, RESETTING\n"); + LogPrint(BCLog::MASTERNODE, "CObfuscationPool::Check() -- timeout, RESETTING\n"); UnlockCoins(); SetNull(); if (fMasterNode) RelayStatus(sessionID, GetState(), GetEntriesCount(), MASTERNODE_RESET); @@ -177,7 +177,7 @@ void CObfuscationPool::CheckFinalTransaction() LOCK2(cs_main, pwalletMain->cs_wallet); { - LogPrint("obfuscation", "Transaction 2: %s\n", txNew.ToString()); + LogPrint(BCLog::MASTERNODE, "Transaction 2: %s\n", txNew.ToString()); // See if the transaction is valid if (!txNew.AcceptToMemoryPool(false, true, true)) { @@ -236,7 +236,7 @@ void CObfuscationPool::CheckFinalTransaction() ChargeRandomFees(); // Reset - LogPrint("obfuscation", "CObfuscationPool::Check() -- COMPLETED -- RESETTING\n"); + LogPrint(BCLog::MASTERNODE, "CObfuscationPool::Check() -- COMPLETED -- RESETTING\n"); SetNull(); RelayStatus(sessionID, GetState(), GetEntriesCount(), MASTERNODE_RESET); } @@ -402,15 +402,15 @@ void CObfuscationPool::CheckTimeout() if (!fMasterNode) { switch (state) { case POOL_STATUS_TRANSMISSION: - LogPrint("obfuscation", "CObfuscationPool::CheckTimeout() -- Session complete -- Running Check()\n"); + LogPrint(BCLog::MASTERNODE, "CObfuscationPool::CheckTimeout() -- Session complete -- Running Check()\n"); Check(); break; case POOL_STATUS_ERROR: - LogPrint("obfuscation", "CObfuscationPool::CheckTimeout() -- Pool error -- Running Check()\n"); + LogPrint(BCLog::MASTERNODE, "CObfuscationPool::CheckTimeout() -- Pool error -- Running Check()\n"); Check(); break; case POOL_STATUS_SUCCESS: - LogPrint("obfuscation", "CObfuscationPool::CheckTimeout() -- Pool success -- Running Check()\n"); + LogPrint(BCLog::MASTERNODE, "CObfuscationPool::CheckTimeout() -- Pool success -- Running Check()\n"); Check(); break; } @@ -421,7 +421,7 @@ void CObfuscationPool::CheckTimeout() std::vector::iterator it = vecObfuscationQueue.begin(); while (it != vecObfuscationQueue.end()) { if ((*it).IsExpired()) { - LogPrint("obfuscation", "CObfuscationPool::CheckTimeout() : Removing expired queue entry - %d\n", c); + LogPrint(BCLog::MASTERNODE, "CObfuscationPool::CheckTimeout() : Removing expired queue entry - %d\n", c); it = vecObfuscationQueue.erase(it); } else ++it; @@ -438,7 +438,7 @@ void CObfuscationPool::CheckTimeout() std::vector::iterator it2 = entries.begin(); while (it2 != entries.end()) { if ((*it2).IsExpired()) { - LogPrint("obfuscation", "CObfuscationPool::CheckTimeout() : Removing expired entry - %d\n", c); + LogPrint(BCLog::MASTERNODE, "CObfuscationPool::CheckTimeout() : Removing expired entry - %d\n", c); it2 = entries.erase(it2); if (entries.size() == 0) { UnlockCoins(); @@ -457,7 +457,7 @@ void CObfuscationPool::CheckTimeout() SetNull(); } } else if (GetTimeMillis() - lastTimeChanged >= (OBFUSCATION_QUEUE_TIMEOUT * 1000) + addLagTime) { - LogPrint("obfuscation", "CObfuscationPool::CheckTimeout() -- Session timed out (%ds) -- resetting\n", OBFUSCATION_QUEUE_TIMEOUT); + LogPrint(BCLog::MASTERNODE, "CObfuscationPool::CheckTimeout() -- Session timed out (%ds) -- resetting\n", OBFUSCATION_QUEUE_TIMEOUT); UnlockCoins(); SetNull(); @@ -466,7 +466,7 @@ void CObfuscationPool::CheckTimeout() } if (state == POOL_STATUS_SIGNING && GetTimeMillis() - lastTimeChanged >= (OBFUSCATION_SIGNING_TIMEOUT * 1000) + addLagTime) { - LogPrint("obfuscation", "CObfuscationPool::CheckTimeout() -- Session timed out (%ds) -- restting\n", OBFUSCATION_SIGNING_TIMEOUT); + LogPrint(BCLog::MASTERNODE, "CObfuscationPool::CheckTimeout() -- Session timed out (%ds) -- restting\n", OBFUSCATION_SIGNING_TIMEOUT); ChargeFees(); UnlockCoins(); SetNull(); @@ -515,7 +515,7 @@ bool CObfuscationPool::SignaturesComplete() void CObfuscationPool::NewBlock() { - LogPrint("obfuscation", "CObfuscationPool::NewBlock \n"); + LogPrint(BCLog::MASTERNODE, "CObfuscationPool::NewBlock \n"); //we we're processing lots of blocks, we'll just leave if (GetTime() - lastNewBlock < 10) return; diff --git a/src/obfuscation.h b/src/obfuscation.h index b9d2dd818da0bf..41eff5c03c1abd 100644 --- a/src/obfuscation.h +++ b/src/obfuscation.h @@ -310,7 +310,7 @@ class CObfuscationPool void UpdateState(unsigned int newState) { if (fMasterNode && (newState == POOL_STATUS_ERROR || newState == POOL_STATUS_SUCCESS)) { - // LogPrint("obfuscation", "CObfuscationPool::UpdateState() - Can't set state to ERROR or SUCCESS as a Masternode. \n"); + // LogPrint(BCLog::MASTERNODE, "CObfuscationPool::UpdateState() - Can't set state to ERROR or SUCCESS as a Masternode. \n"); return; } diff --git a/src/protocol.cpp b/src/protocol.cpp index 381554e17cc0ba..a8b02b9fd626fc 100644 --- a/src/protocol.cpp +++ b/src/protocol.cpp @@ -124,7 +124,7 @@ CInv::CInv(const std::string& strType, const uint256& hashIn) } } if (i == ARRAYLEN(ppszTypeName)) - LogPrint("net", "CInv::CInv(string, uint256) : unknown type '%s'", strType); + LogPrint(BCLog::NET, "CInv::CInv(string, uint256) : unknown type '%s'", strType); hash = hashIn; } @@ -145,7 +145,7 @@ bool CInv::IsMasterNodeType() const{ const char* CInv::GetCommand() const { if (!IsKnownType()) { - LogPrint("net", "CInv::GetCommand() : type=%d unknown type", type); + LogPrint(BCLog::NET, "CInv::GetCommand() : type=%d unknown type", type); return "UNKNOWN"; } diff --git a/src/qt/pivx.cpp b/src/qt/pivx.cpp index 5ad73deffa24cb..aa11d5466e8d92 100644 --- a/src/qt/pivx.cpp +++ b/src/qt/pivx.cpp @@ -141,8 +141,11 @@ static void initTranslations(QTranslator& qtTranslatorBase, QTranslator& qtTrans void DebugMessageHandler(QtMsgType type, const QMessageLogContext& context, const QString& msg) { Q_UNUSED(context); - const char* category = (type == QtDebugMsg) ? "qt" : NULL; - LogPrint(category, "GUI: %s\n", msg.toStdString()); + if (type == QtDebugMsg) { + LogPrint(BCLog::QT, "GUI: %s\n", msg.toStdString()); + } else { + LogPrintf("GUI: %s\n", msg.toStdString()); + } } /** Class encapsulating PIVX Core startup and shutdown. diff --git a/src/qt/transactiondesc.cpp b/src/qt/transactiondesc.cpp index 69a5b48e7d214c..59a89e66607646 100644 --- a/src/qt/transactiondesc.cpp +++ b/src/qt/transactiondesc.cpp @@ -274,7 +274,7 @@ QString TransactionDesc::toHTML(CWallet* wallet, CWalletTx& wtx, TransactionReco // // Debug view // - if (fDebug) { + if (logCategories != BCLog::NONE) { strHTML += "

" + tr("Debug information") + "

"; for (const CTxIn& txin : wtx.vin) if (wallet->IsMine(txin)) diff --git a/src/qt/winshutdownmonitor.cpp b/src/qt/winshutdownmonitor.cpp index e8e8d31b1ecb8f..bff62dc9699a57 100644 --- a/src/qt/winshutdownmonitor.cpp +++ b/src/qt/winshutdownmonitor.cpp @@ -28,7 +28,7 @@ bool WinShutdownMonitor::nativeEventFilter(const QByteArray& eventType, void* pM // Warn only once as this is performance-critical static bool warned = false; if (!warned) { - LogPrint("%s: OpenSSL RAND_event() failed to seed OpenSSL PRNG with enough data.\n", __func__); + LogPrintf("%s: OpenSSL RAND_event() failed to seed OpenSSL PRNG with enough data.\n", __func__); warned = true; } } diff --git a/src/random.cpp b/src/random.cpp index cc20ced5b1c917..55c6eea80f9c3a 100644 --- a/src/random.cpp +++ b/src/random.cpp @@ -166,7 +166,7 @@ static void RandAddSeedPerfmon() if (ret == ERROR_SUCCESS) { RAND_add(vData.data(), nSize, nSize / 100.0); memory_cleanse(vData.data(), nSize); - LogPrint("rand", "%s: %lu bytes\n", __func__, nSize); + LogPrint(BCLog::RAND, "%s: %lu bytes\n", __func__, nSize); } else { static bool warned = false; // Warn only once if (!warned) { diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 2b16324bf597ec..5a47fc954698b7 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -497,7 +497,7 @@ const CRPCCommand *CRPCTable::operator[](const std::string &name) const bool StartRPC() { - LogPrint("rpc", "Starting RPC\n"); + LogPrint(BCLog::RPC, "Starting RPC\n"); fRPCRunning = true; g_rpcSignals.Started(); return true; @@ -505,14 +505,14 @@ bool StartRPC() void InterruptRPC() { - LogPrint("rpc", "Interrupting RPC\n"); + LogPrint(BCLog::RPC, "Interrupting RPC\n"); // Interrupt e.g. running longpolls fRPCRunning = false; } void StopRPC() { - LogPrint("rpc", "Stopping RPC\n"); + LogPrint(BCLog::RPC, "Stopping RPC\n"); deadlineTimers.clear(); g_rpcSignals.Stopped(); } @@ -561,7 +561,7 @@ void JSONRequest::parse(const UniValue& valRequest) throw JSONRPCError(RPC_INVALID_REQUEST, "Method must be a string"); strMethod = valMethod.get_str(); if (strMethod != "getblocktemplate") - LogPrint("rpc", "ThreadRPCServer method=%s\n", SanitizeString(strMethod)); + LogPrint(BCLog::RPC, "ThreadRPCServer method=%s\n", SanitizeString(strMethod)); // Parse params UniValue valParams = find_value(request, "params"); @@ -667,7 +667,7 @@ void RPCRunLater(const std::string& name, boost::function func, int6 if (!timerInterface) throw JSONRPCError(RPC_INTERNAL_ERROR, "No timer handler registered for RPC"); deadlineTimers.erase(name); - LogPrint("rpc", "queue run of timer %s in %i seconds (using %s)\n", name, nSeconds, timerInterface->Name()); + LogPrint(BCLog::RPC, "queue run of timer %s in %i seconds (using %s)\n", name, nSeconds, timerInterface->Name()); deadlineTimers.insert(std::make_pair(name, boost::shared_ptr(timerInterface->NewTimer(func, nSeconds*1000)))); } diff --git a/src/spork.cpp b/src/spork.cpp index df79e4e7be1682..78819db1766c11 100644 --- a/src/spork.cpp +++ b/src/spork.cpp @@ -234,7 +234,7 @@ std::string CSporkManager::GetSporkNameByID(SporkId nSporkID) { auto it = sporkDefsById.find(nSporkID); if (it == sporkDefsById.end()) { - LogPrint("%s : Unknown Spork ID %d\n", __func__, nSporkID); + LogPrintf("%s : Unknown Spork ID %d\n", __func__, nSporkID); return "Unknown"; } return it->second->name; diff --git a/src/swifttx.cpp b/src/swifttx.cpp index bc3eafb310ce6e..2304378ad00e33 100644 --- a/src/swifttx.cpp +++ b/src/swifttx.cpp @@ -199,12 +199,12 @@ bool IsIXTXValid(const CTransaction& txCollateral) } if (nValueOut > sporkManager.GetSporkValue(SPORK_5_MAX_VALUE) * COIN) { - LogPrint("swiftx", "%s : Transaction value too high - %s\n", __func__, txCollateral.ToString().c_str()); + LogPrint(BCLog::MASTERNODE, "%s : Transaction value too high - %s\n", __func__, txCollateral.ToString().c_str()); return false; } if (missingTx) { - LogPrint("swiftx", "%s : Unknown inputs in IX transaction - %s\n", __func__, txCollateral.ToString().c_str()); + LogPrint(BCLog::MASTERNODE, "%s : Unknown inputs in IX transaction - %s\n", __func__, txCollateral.ToString().c_str()); /* This happens sometimes for an unknown reason, so we'll return that it's a valid transaction. If someone submits an invalid transaction it will be rejected by the network anyway and this isn't @@ -214,7 +214,7 @@ bool IsIXTXValid(const CTransaction& txCollateral) } if (nValueIn - nValueOut < COIN * 0.01) { - LogPrint("swiftx", "%s : did not include enough fees in transaction %d\n%s\n", __func__, nValueOut - nValueIn, txCollateral.ToString().c_str()); + LogPrint(BCLog::MASTERNODE, "%s : did not include enough fees in transaction %d\n%s\n", __func__, nValueOut - nValueIn, txCollateral.ToString().c_str()); return false; } @@ -252,7 +252,7 @@ int64_t CreateNewLock(CTransaction tx) mapTxLocks.insert(std::make_pair(tx.GetHash(), newLock)); } else { mapTxLocks[tx.GetHash()].nBlockHeight = nBlockHeight; - LogPrint("swiftx", "%s : Transaction Lock Exists %s !\n", __func__, tx.GetHash().ToString().c_str()); + LogPrint(BCLog::MASTERNODE, "%s : Transaction Lock Exists %s !\n", __func__, tx.GetHash().ToString().c_str()); } @@ -267,19 +267,19 @@ void DoConsensusVote(CTransaction& tx, int64_t nBlockHeight) int n = mnodeman.GetMasternodeRank(activeMasternode.vin, nBlockHeight, MIN_SWIFTTX_PROTO_VERSION); if (n == -1) { - LogPrint("swiftx", "%s : Unknown Masternode\n", __func__); + LogPrint(BCLog::MASTERNODE, "%s : Unknown Masternode\n", __func__); return; } if (n > SWIFTTX_SIGNATURES_TOTAL) { - LogPrint("swiftx", "%s : Masternode not in the top %d (%d)\n", __func__, SWIFTTX_SIGNATURES_TOTAL, n); + LogPrint(BCLog::MASTERNODE, "%s : Masternode not in the top %d (%d)\n", __func__, SWIFTTX_SIGNATURES_TOTAL, n); return; } /* nBlockHeight calculated from the transaction is the authoritive source */ - LogPrint("swiftx", "%s : In the top %d (%d)\n", __func__, SWIFTTX_SIGNATURES_TOTAL, n); + LogPrint(BCLog::MASTERNODE, "%s : In the top %d (%d)\n", __func__, SWIFTTX_SIGNATURES_TOTAL, n); CConsensusVote ctx; ctx.vinMasternode = activeMasternode.vin; @@ -312,17 +312,17 @@ bool ProcessConsensusVote(CNode* pnode, CConsensusVote& ctx) CMasternode* pmn = mnodeman.Find(ctx.vinMasternode); if (pmn != NULL) - LogPrint("swiftx", "%s : Masternode ADDR %s %d\n", __func__, pmn->addr.ToString().c_str(), n); + LogPrint(BCLog::MASTERNODE, "%s : Masternode ADDR %s %d\n", __func__, pmn->addr.ToString().c_str(), n); if (n == -1) { //can be caused by past versions trying to vote with an invalid protocol - LogPrint("swiftx", "%s : Unknown Masternode\n", __func__); + LogPrint(BCLog::MASTERNODE, "%s : Unknown Masternode\n", __func__); mnodeman.AskForMN(pnode, ctx.vinMasternode); return false; } if (n > SWIFTTX_SIGNATURES_TOTAL) { - LogPrint("swiftx", "%s : Masternode not in the top %d (%d) - %s\n", __func__, + LogPrint(BCLog::MASTERNODE, "%s : Masternode not in the top %d (%d) - %s\n", __func__, SWIFTTX_SIGNATURES_TOTAL, n, ctx.GetHash().ToString().c_str()); return false; } @@ -343,7 +343,7 @@ bool ProcessConsensusVote(CNode* pnode, CConsensusVote& ctx) newLock.txHash = ctx.txHash; mapTxLocks.insert(std::make_pair(ctx.txHash, newLock)); } else - LogPrint("swiftx", "%s : Transaction Lock Exists %s !\n", __func__, ctx.txHash.ToString().c_str()); + LogPrint(BCLog::MASTERNODE, "%s : Transaction Lock Exists %s !\n", __func__, ctx.txHash.ToString().c_str()); //compile consessus vote std::map::iterator i = mapTxLocks.find(ctx.txHash); @@ -358,10 +358,10 @@ bool ProcessConsensusVote(CNode* pnode, CConsensusVote& ctx) } #endif - LogPrint("swiftx", "%s : Transaction Lock Votes %d - %s !\n", __func__, (*i).second.CountSignatures(), ctx.GetHash().ToString().c_str()); + LogPrint(BCLog::MASTERNODE, "%s : Transaction Lock Votes %d - %s !\n", __func__, (*i).second.CountSignatures(), ctx.GetHash().ToString().c_str()); if ((*i).second.CountSignatures() >= SWIFTTX_SIGNATURES_REQUIRED) { - LogPrint("swiftx", "%s : Transaction Lock Is Complete %s !\n", __func__, (*i).second.GetHash().ToString().c_str()); + LogPrint(BCLog::MASTERNODE, "%s : Transaction Lock Is Complete %s !\n", __func__, (*i).second.GetHash().ToString().c_str()); CTransaction& tx = mapTxLockReq[ctx.txHash]; if (!CheckForConflictingLocks(tx)) { diff --git a/src/timedata.cpp b/src/timedata.cpp index 57a88afb766dc2..b16e135d8dcf18 100644 --- a/src/timedata.cpp +++ b/src/timedata.cpp @@ -82,7 +82,7 @@ void AddTimeData(const CNetAddr& ip, int64_t nOffsetSample, int nOffsetLimit) LogPrintf("*** %s\n", strMessage); uiInterface.ThreadSafeMessageBox(strMessage, "", CClientUIInterface::MSG_ERROR); } - if (fDebug) { + if (logCategories != BCLog::NONE) { for (int64_t n : vSorted) LogPrintf("%+d ", n); LogPrintf("| "); diff --git a/src/torcontrol.cpp b/src/torcontrol.cpp index e23c3c1d212fda..37c12f1362e123 100644 --- a/src/torcontrol.cpp +++ b/src/torcontrol.cpp @@ -164,7 +164,7 @@ void TorControlConnection::readcb(struct bufferevent *bev, void *ctx) self->reply_handlers.front()(*self, self->message); self->reply_handlers.pop_front(); } else { - LogPrint("tor", "tor: Received unexpected sync reply %i\n", self->message.code); + LogPrint(BCLog::TOR, "tor: Received unexpected sync reply %i\n", self->message.code); } } self->message.Clear(); @@ -183,13 +183,13 @@ void TorControlConnection::eventcb(struct bufferevent *bev, short what, void *ct { TorControlConnection *self = (TorControlConnection*)ctx; if (what & BEV_EVENT_CONNECTED) { - LogPrint("tor", "tor: Successfully connected!\n"); + LogPrint(BCLog::TOR, "tor: Successfully connected!\n"); self->connected(*self); } else if (what & (BEV_EVENT_EOF|BEV_EVENT_ERROR)) { if (what & BEV_EVENT_ERROR) { - LogPrint("tor", "tor: Error connecting to Tor control socket\n"); + LogPrint(BCLog::TOR, "tor: Error connecting to Tor control socket\n"); } else { - LogPrint("tor", "tor: End of stream\n"); + LogPrint(BCLog::TOR, "tor: End of stream\n"); } self->Disconnect(); self->disconnected(*self); @@ -468,7 +468,7 @@ TorController::TorController(struct event_base* _base, const std::string& _targe // Read service private key if cached std::pair pkf = ReadBinaryFile(GetPrivateKeyFile()); if (pkf.first) { - LogPrint("tor", "tor: Reading cached private key from %s\n", GetPrivateKeyFile()); + LogPrint(BCLog::TOR, "tor: Reading cached private key from %s\n", GetPrivateKeyFile()); private_key = pkf.second; } } @@ -487,7 +487,7 @@ TorController::~TorController() void TorController::add_onion_cb(TorControlConnection& _conn, const TorControlReply& reply) { if (reply.code == 250) { - LogPrint("tor", "tor: ADD_ONION successful\n"); + LogPrint(BCLog::TOR, "tor: ADD_ONION successful\n"); for (const std::string &s : reply.lines) { std::map m = ParseTorReplyMapping(s); std::map::iterator i; @@ -506,7 +506,7 @@ void TorController::add_onion_cb(TorControlConnection& _conn, const TorControlRe LookupNumeric(std::string(service_id+".onion").c_str(), service, GetListenPort()); LogPrintf("tor: Got service ID %s, advertising service %s\n", service_id, service.ToString()); if (WriteBinaryFile(GetPrivateKeyFile(), private_key)) { - LogPrint("tor", "tor: Cached service private key to %s\n", GetPrivateKeyFile()); + LogPrint(BCLog::TOR, "tor: Cached service private key to %s\n", GetPrivateKeyFile()); } else { LogPrintf("tor: Error writing service private key to %s\n", GetPrivateKeyFile()); } @@ -522,7 +522,7 @@ void TorController::add_onion_cb(TorControlConnection& _conn, const TorControlRe void TorController::auth_cb(TorControlConnection& _conn, const TorControlReply& reply) { if (reply.code == 250) { - LogPrint("tor", "tor: Authentication successful\n"); + LogPrint(BCLog::TOR, "tor: Authentication successful\n"); // Now that we know Tor is running setup the proxy for onion addresses // if -onion isn't set to something else. @@ -577,7 +577,7 @@ static std::vector ComputeResponse(const std::string &key, const std::v void TorController::authchallenge_cb(TorControlConnection& _conn, const TorControlReply& reply) { if (reply.code == 250) { - LogPrint("tor", "tor: SAFECOOKIE authentication challenge successful\n"); + LogPrint(BCLog::TOR, "tor: SAFECOOKIE authentication challenge successful\n"); std::pair l = SplitTorReplyLine(reply.lines[0]); if (l.first == "AUTHCHALLENGE") { std::map m = ParseTorReplyMapping(l.second); @@ -587,7 +587,7 @@ void TorController::authchallenge_cb(TorControlConnection& _conn, const TorContr } std::vector serverHash = ParseHex(m["SERVERHASH"]); std::vector serverNonce = ParseHex(m["SERVERNONCE"]); - LogPrint("tor", "tor: AUTHCHALLENGE ServerHash %s ServerNonce %s\n", HexStr(serverHash), HexStr(serverNonce)); + LogPrint(BCLog::TOR, "tor: AUTHCHALLENGE ServerHash %s ServerNonce %s\n", HexStr(serverHash), HexStr(serverNonce)); if (serverNonce.size() != 32) { LogPrintf("tor: ServerNonce is not 32 bytes, as required by spec\n"); return; @@ -632,12 +632,12 @@ void TorController::protocolinfo_cb(TorControlConnection& _conn, const TorContro std::map m = ParseTorReplyMapping(l.second); std::map::iterator i; if ((i = m.find("Tor")) != m.end()) { - LogPrint("tor", "tor: Connected to Tor version %s\n", i->second); + LogPrint(BCLog::TOR, "tor: Connected to Tor version %s\n", i->second); } } } for (const std::string &s : methods) { - LogPrint("tor", "tor: Supported authentication method: %s\n", s); + LogPrint(BCLog::TOR, "tor: Supported authentication method: %s\n", s); } // Prefer NULL, otherwise SAFECOOKIE. If a password is provided, use HASHEDPASSWORD /* Authentication: @@ -647,18 +647,18 @@ void TorController::protocolinfo_cb(TorControlConnection& _conn, const TorContro std::string torpassword = GetArg("-torpassword", ""); if (!torpassword.empty()) { if (methods.count("HASHEDPASSWORD")) { - LogPrint("tor", "tor: Using HASHEDPASSWORD authentication\n"); + LogPrint(BCLog::TOR, "tor: Using HASHEDPASSWORD authentication\n"); boost::replace_all(torpassword, "\"", "\\\""); _conn.Command("AUTHENTICATE \"" + torpassword + "\"", boost::bind(&TorController::auth_cb, this, _1, _2)); } else { LogPrintf("tor: Password provided with -torpassword, but HASHEDPASSWORD authentication is not available\n"); } } else if (methods.count("NULL")) { - LogPrint("tor", "tor: Using NULL authentication\n"); + LogPrint(BCLog::TOR, "tor: Using NULL authentication\n"); _conn.Command("AUTHENTICATE", boost::bind(&TorController::auth_cb, this, _1, _2)); } else if (methods.count("SAFECOOKIE")) { // Cookie: hexdump -e '32/1 "%02x""\n"' ~/.tor/control_auth_cookie - LogPrint("tor", "tor: Using SAFECOOKIE authentication, reading cookie authentication from %s\n", cookiefile); + LogPrint(BCLog::TOR, "tor: Using SAFECOOKIE authentication, reading cookie authentication from %s\n", cookiefile); std::pair status_cookie = ReadBinaryFile(cookiefile, TOR_COOKIE_SIZE); if (status_cookie.first && status_cookie.second.size() == TOR_COOKIE_SIZE) { // _conn.Command("AUTHENTICATE " + HexStr(status_cookie.second), boost::bind(&TorController::auth_cb, this, _1, _2)); @@ -700,7 +700,7 @@ void TorController::disconnected_cb(TorControlConnection& _conn) if (!reconnect) return; - LogPrint("tor", "tor: Not connected to Tor control port %s, trying to reconnect\n", target); + LogPrint(BCLog::TOR, "tor: Not connected to Tor control port %s, trying to reconnect\n", target); // Single-shot timer for reconnect. Use exponential backoff. struct timeval time = MillisToTimeval(int64_t(reconnect_timeout * 1000.0)); @@ -780,4 +780,4 @@ void StopTorControl() event_base_free(gBase); gBase = 0; } -} \ No newline at end of file +} diff --git a/src/txdb.cpp b/src/txdb.cpp index e507b602663eed..c89a1991e236d2 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -67,7 +67,7 @@ bool CCoinsViewDB::BatchWrite(CCoinsMap& mapCoins, const uint256& hashBlock) if (!hashBlock.IsNull()) BatchWriteHashBestChain(batch, hashBlock); - LogPrint("coindb", "Committing %u changed transactions (out of %u) to coin database...\n", (unsigned int)changed, (unsigned int)count); + LogPrint(BCLog::COINDB, "Committing %u changed transactions (out of %u) to coin database...\n", (unsigned int)changed, (unsigned int)count); return db.WriteBatch(batch); } @@ -285,7 +285,7 @@ bool CZerocoinDB::WriteCoinMintBatch(const std::vector 0) - LogPrint("estimatefee", "Read %d fee samples and %d priority samples\n", + LogPrint(BCLog::ESTIMATEFEE, "Read %d fee samples and %d priority samples\n", feeSamples.size(), prioritySamples.size()); } }; @@ -185,7 +185,7 @@ class CMinerPolicyEstimator // Neither or both fee and priority sufficient to get confirmed: // don't know why they got confirmed. } - LogPrint("estimatefee", "Seen TX confirm: %s : %s fee/%g priority, took %d blocks\n", + LogPrint(BCLog::ESTIMATEFEE, "Seen TX confirm: %s : %s fee/%g priority, took %d blocks\n", assignedTo, feeRate.ToString(), dPriority, nBlocksAgo); } @@ -246,7 +246,7 @@ class CMinerPolicyEstimator for (size_t i = 0; i < history.size(); i++) { if (history[i].FeeSamples() + history[i].PrioritySamples() > 0) - LogPrint("estimatefee", "estimates: for confirming within %d blocks based on %d/%d samples, fee=%s, prio=%g\n", + LogPrint(BCLog::ESTIMATEFEE, "estimates: for confirming within %d blocks based on %d/%d samples, fee=%s, prio=%g\n", i, history[i].FeeSamples(), history[i].PrioritySamples(), estimateFee(i + 1).ToString(), estimatePriority(i + 1)); @@ -542,7 +542,7 @@ void CTxMemPool::check(const CCoinsViewCache* pcoins) const if (!fSanityCheck) return; - LogPrint("mempool", "Checking mempool with %u transactions and %u inputs\n", (unsigned int)mapTx.size(), (unsigned int)mapNextTx.size()); + LogPrint(BCLog::MEMPOOL, "Checking mempool with %u transactions and %u inputs\n", (unsigned int)mapTx.size(), (unsigned int)mapNextTx.size()); uint64_t checkTotal = 0; diff --git a/src/util.cpp b/src/util.cpp index f675220d73dc50..5015be124f3f1e 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -104,7 +104,6 @@ std::string strBudgetMode = ""; std::map mapArgs; std::map > mapMultiArgs; -bool fDebug = false; bool fPrintToConsole = false; bool fPrintToDebugLog = true; bool fDaemon = false; @@ -113,6 +112,10 @@ bool fLogTimestamps = false; bool fLogIPs = false; volatile bool fReopenDebugLog = false; +/** Log categories bitfield. Leveldb/libevent need special handling if their flags are changed at runtime. */ +std::atomic logCategories(0); + + /** Init OpenSSL library multithreading support */ static RecursiveMutex** ppmutexOpenSSL; void locking_callback(int mode, int i, const char* file, int line) NO_THREAD_SAFETY_ANALYSIS @@ -194,40 +197,73 @@ static void DebugPrintInit() mutexDebugLog = new boost::mutex(); } -bool LogAcceptCategory(const char* category) -{ - if (category != NULL) { - if (!fDebug) - return false; - - // Give each thread quick access to -debug settings. - // This helps prevent issues debugging global destructors, - // where mapMultiArgs might be deleted before another - // global destructor calls LogPrint() - static boost::thread_specific_ptr > ptrCategory; - if (ptrCategory.get() == NULL) { - const std::vector& categories = mapMultiArgs["-debug"]; - ptrCategory.reset(new std::set(categories.begin(), categories.end())); - // thread_specific_ptr automatically deletes the set when the thread ends. - // "pivx" is a composite category enabling all PIVX-related debug output - if (ptrCategory->count(std::string("pivx"))) { - ptrCategory->insert(std::string("obfuscation")); - ptrCategory->insert(std::string("swiftx")); - ptrCategory->insert(std::string("masternode")); - ptrCategory->insert(std::string("mnpayments")); - ptrCategory->insert(std::string("zero")); - ptrCategory->insert(std::string("mnbudget")); - ptrCategory->insert(std::string("staking")); +struct CLogCategoryDesc +{ + uint32_t flag; + std::string category; +}; + +const CLogCategoryDesc LogCategories[] = { + {BCLog::NONE, "0"}, + {BCLog::NET, "net"}, + {BCLog::TOR, "tor"}, + {BCLog::MEMPOOL, "mempool"}, + {BCLog::HTTP, "http"}, + {BCLog::BENCH, "bench"}, + {BCLog::ZMQ, "zmq"}, + {BCLog::DB, "db"}, + {BCLog::RPC, "rpc"}, + {BCLog::ESTIMATEFEE, "estimatefee"}, + {BCLog::ADDRMAN, "addrman"}, + {BCLog::SELECTCOINS, "selectcoins"}, + {BCLog::REINDEX, "reindex"}, + {BCLog::CMPCTBLOCK, "cmpctblock"}, + {BCLog::RAND, "rand"}, + {BCLog::PRUNE, "prune"}, + {BCLog::PROXY, "proxy"}, + {BCLog::MEMPOOLREJ, "mempoolrej"}, + {BCLog::LIBEVENT, "libevent"}, + {BCLog::COINDB, "coindb"}, + {BCLog::QT, "qt"}, + {BCLog::LEVELDB, "leveldb"}, + {BCLog::STAKING, "staking"}, + {BCLog::MASTERNODE, "masternode"}, + {BCLog::MNBUDGET, "mnbudget"}, + {BCLog::LEGACYZC, "zero"}, + {BCLog::ALL, "1"}, + {BCLog::ALL, "all"}, +}; + +bool GetLogCategory(uint32_t *f, const std::string *str) +{ + if (f && str) { + if (*str == "") { + *f = BCLog::ALL; + return true; + } + for (unsigned int i = 0; i < ARRAYLEN(LogCategories); i++) { + if (LogCategories[i].category == *str) { + *f = LogCategories[i].flag; + return true; } } - const std::set& setCategories = *ptrCategory.get(); + } + return false; +} - // if not debugging everything and not debugging specific category, LogPrint does nothing. - if (setCategories.count(std::string("")) == 0 && - setCategories.count(std::string(category)) == 0) - return false; +std::string ListLogCategories() +{ + std::string ret; + int outcount = 0; + for (unsigned int i = 0; i < ARRAYLEN(LogCategories); i++) { + // Omit the special cases. + if (LogCategories[i].flag != BCLog::NONE && LogCategories[i].flag != BCLog::ALL) { + if (outcount != 0) ret += ", "; + ret += LogCategories[i].category; + outcount++; + } } - return true; + return ret; } int LogPrintStr(const std::string& str) diff --git a/src/util.h b/src/util.h index 7ac072bccabe64..573514d40e036e 100644 --- a/src/util.h +++ b/src/util.h @@ -21,6 +21,7 @@ #include "utiltime.h" #include "util/threadnames.h" +#include #include #include #include @@ -43,10 +44,9 @@ extern int keysLoaded; extern bool fSucessfullyLoaded; extern std::vector obfuScationDenominations; extern std::string strBudgetMode; - +extern std::atomic logCategories; extern std::map mapArgs; extern std::map > mapMultiArgs; -extern bool fDebug; extern bool fPrintToConsole; extern bool fPrintToDebugLog; extern std::string strMiscWarning; @@ -57,8 +57,48 @@ extern volatile bool fReopenDebugLog; void SetupEnvironment(); bool SetupNetworking(); +namespace BCLog { + enum LogFlags : uint32_t { + NONE = 0, + NET = (1 << 0), + TOR = (1 << 1), + MEMPOOL = (1 << 2), + HTTP = (1 << 3), + BENCH = (1 << 4), + ZMQ = (1 << 5), + DB = (1 << 6), + RPC = (1 << 7), + ESTIMATEFEE = (1 << 8), + ADDRMAN = (1 << 9), + SELECTCOINS = (1 << 10), + REINDEX = (1 << 11), + CMPCTBLOCK = (1 << 12), + RAND = (1 << 13), + PRUNE = (1 << 14), + PROXY = (1 << 15), + MEMPOOLREJ = (1 << 16), + LIBEVENT = (1 << 17), + COINDB = (1 << 18), + QT = (1 << 19), + LEVELDB = (1 << 20), + STAKING = (1 << 21), + MASTERNODE = (1 << 22), + MNBUDGET = (1 << 23), + LEGACYZC = (1 << 24), + ALL = ~(uint32_t)0, + }; +} + /** Return true if log accepts specified category */ -bool LogAcceptCategory(const char* category); +static inline bool LogAcceptCategory(uint32_t category) +{ + return (logCategories.load(std::memory_order_relaxed) & category) != 0; +} + +/** Returns a string with the supported log categories */ +std::string ListLogCategories(); +/** Return true if str parses as a log category and set the flags in f */ +bool GetLogCategory(uint32_t *f, const std::string *str); /** Send a string to the log output */ int LogPrintStr(const std::string& str); diff --git a/src/wallet/db.cpp b/src/wallet/db.cpp index 5383e80cc6b76f..31d5512b0c4359 100644 --- a/src/wallet/db.cpp +++ b/src/wallet/db.cpp @@ -123,7 +123,7 @@ void CDBEnv::MakeMock() boost::this_thread::interruption_point(); - LogPrint("db", "CDBEnv::MakeMock\n"); + LogPrint(BCLog::DB, "CDBEnv::MakeMock\n"); dbenv->set_cachesize(1, 0, 1); dbenv->set_lg_bsize(10485760 * 4); @@ -426,7 +426,7 @@ void CDBEnv::Flush(bool fShutdown) { int64_t nStart = GetTimeMillis(); // Flush log data to the actual data file on all files that are not in use - LogPrint("db", "CDBEnv::Flush : Flush(%s)%s\n", fShutdown ? "true" : "false", fDbEnvInit ? "" : " database not started"); + LogPrint(BCLog::DB, "CDBEnv::Flush : Flush(%s)%s\n", fShutdown ? "true" : "false", fDbEnvInit ? "" : " database not started"); if (!fDbEnvInit) return; { @@ -435,21 +435,21 @@ void CDBEnv::Flush(bool fShutdown) while (mi != mapFileUseCount.end()) { std::string strFile = (*mi).first; int nRefCount = (*mi).second; - LogPrint("db", "CDBEnv::Flush : Flushing %s (refcount = %d)...\n", strFile, nRefCount); + LogPrint(BCLog::DB, "CDBEnv::Flush : Flushing %s (refcount = %d)...\n", strFile, nRefCount); if (nRefCount == 0) { // Move log data to the dat file CloseDb(strFile); - LogPrint("db", "CDBEnv::Flush: %s checkpoint\n", strFile); + LogPrint(BCLog::DB, "CDBEnv::Flush: %s checkpoint\n", strFile); dbenv->txn_checkpoint(0, 0, 0); - LogPrint("db", "CDBEnv::Flush: %s detach\n", strFile); + LogPrint(BCLog::DB, "CDBEnv::Flush: %s detach\n", strFile); if (!fMockDb) dbenv->lsn_reset(strFile.c_str(), 0); - LogPrint("db", "CDBEnv::Flush: %s closed\n", strFile); + LogPrint(BCLog::DB, "CDBEnv::Flush: %s closed\n", strFile); mapFileUseCount.erase(mi++); } else mi++; } - LogPrint("db", "CDBEnv::Flush : Flush(%s)%s took %15dms\n", fShutdown ? "true" : "false", fDbEnvInit ? "" : " database not started", GetTimeMillis() - nStart); + LogPrint(BCLog::DB, "CDBEnv::Flush : Flush(%s)%s took %15dms\n", fShutdown ? "true" : "false", fDbEnvInit ? "" : " database not started", GetTimeMillis() - nStart); if (fShutdown) { char** listp; if (mapFileUseCount.empty()) { diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 8fe4668adae8fe..c07378633f8bbe 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1577,7 +1577,7 @@ int CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate, b for (auto& m : listMints) { if (IsMyMint(m.GetValue())) { - LogPrint("zero", "%s: found mint\n", __func__); + LogPrint(BCLog::LEGACYZC, "%s: found mint\n", __func__); pwalletMain->UpdateMint(m.GetValue(), pindex->nHeight, m.GetTxHash(), m.GetDenomination()); // Add the transaction to the wallet @@ -2110,7 +2110,7 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int // try to find nondenom first to prevent unneeded spending of mixed coins for (unsigned int tryDenom = 0; tryDenom < 2; tryDenom++) { - if (fDebug) LogPrint("selectcoins", "tryDenom: %d\n", tryDenom); + LogPrint(BCLog::SELECTCOINS, "tryDenom: %d\n", tryDenom); vValue.clear(); nTotalLower = 0; for (const COutput& output : vCoins) { @@ -2119,7 +2119,6 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int const CWalletTx* pcoin = output.tx; - // if (fDebug) LogPrint("selectcoins", "value %s confirms %d\n", FormatMoney(pcoin->vout[output.i].nValue), output.nDepth); if (output.nDepth < (pcoin->IsFromMe(ISMINE_ALL) ? nConfMine : nConfTheirs)) continue; @@ -2642,7 +2641,7 @@ bool CWallet::CreateCoinStake( break; } - LogPrint("staking", "%s: attempted staking %d times\n", __func__, nAttempts); + LogPrint(BCLog::STAKING, "%s: attempted staking %d times\n", __func__, nAttempts); if (!fKernelFound) return false; diff --git a/src/wallet/wallet_zerocoin.cpp b/src/wallet/wallet_zerocoin.cpp index a5f4da6e48b899..5d445177d9c2d1 100644 --- a/src/wallet/wallet_zerocoin.cpp +++ b/src/wallet/wallet_zerocoin.cpp @@ -168,7 +168,7 @@ bool CWallet::CreateZerocoinMintTransaction(const CAmount nValue, txNew.vout.push_back(outMint); //store as CZerocoinMint for later use - LogPrint("zero", "%s: new mint %s\n", __func__, dMint.ToString()); + LogPrint(BCLog::LEGACYZC, "%s: new mint %s\n", __func__, dMint.ToString()); vDMints.emplace_back(dMint); } diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index 7bba4ab93d38e8..9235e8a4282bf8 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -886,7 +886,7 @@ void ThreadFlushWalletDB(const std::string& strFile) boost::this_thread::interruption_point(); std::map::iterator mi = bitdb.mapFileUseCount.find(strFile); if (mi != bitdb.mapFileUseCount.end()) { - LogPrint("db", "Flushing wallet.dat\n"); + LogPrint(BCLog::DB, "Flushing wallet.dat\n"); nLastFlushed = nWalletDBUpdated; int64_t nStart = GetTimeMillis(); @@ -895,7 +895,7 @@ void ThreadFlushWalletDB(const std::string& strFile) bitdb.CheckpointLSN(strFile); bitdb.mapFileUseCount.erase(mi++); - LogPrint("db", "Flushed wallet.dat %dms\n", GetTimeMillis() - nStart); + LogPrint(BCLog::DB, "Flushed wallet.dat %dms\n", GetTimeMillis() - nStart); } } } @@ -905,7 +905,7 @@ void ThreadFlushWalletDB(const std::string& strFile) void NotifyBacked(const CWallet& wallet, bool fSuccess, std::string strMessage) { - LogPrint(nullptr, strMessage.data()); + LogPrintf("%s\n", strMessage); wallet.NotifyWalletBacked(fSuccess, strMessage); } @@ -998,7 +998,6 @@ bool BackupWallet(const CWallet& wallet, const boost::filesystem::path& strDest, } } catch (const boost::filesystem::filesystem_error& error) { std::string strMessage = strprintf("Failed to delete backup %s\n", error.what()); - LogPrint(nullptr, strMessage.data()); NotifyBacked(wallet, false, strMessage); } } @@ -1034,12 +1033,12 @@ bool AttemptBackupWallet(const CWallet& wallet, const boost::filesystem::path& p dst.close(); #endif strMessage = strprintf("copied wallet.dat to %s\n", pathDest.string()); - LogPrint(nullptr, strMessage.data()); + LogPrintf("%s : %s\n", __func__, strMessage); retStatus = true; } catch (const boost::filesystem::filesystem_error& e) { retStatus = false; strMessage = strprintf("%s\n", e.what()); - LogPrint(nullptr, strMessage.data()); + LogPrintf("%s : %s\n", __func__, strMessage); } NotifyBacked(wallet, retStatus, strMessage); return retStatus; diff --git a/src/zmq/zmqnotificationinterface.cpp b/src/zmq/zmqnotificationinterface.cpp index b99b4293080aed..dce64d937bf949 100644 --- a/src/zmq/zmqnotificationinterface.cpp +++ b/src/zmq/zmqnotificationinterface.cpp @@ -12,7 +12,7 @@ void zmqError(const char *str) { - LogPrint("zmq", "zmq: Error: %s, errno=%s\n", str, zmq_strerror(errno)); + LogPrint(BCLog::ZMQ, "Error: %s, errno=%s\n", str, zmq_strerror(errno)); } CZMQNotificationInterface::CZMQNotificationInterface() : pcontext(NULL) @@ -74,7 +74,7 @@ CZMQNotificationInterface* CZMQNotificationInterface::CreateWithArguments(const // Called at startup to conditionally set up ZMQ socket(s) bool CZMQNotificationInterface::Initialize() { - LogPrint("zmq", "zmq: Initialize notification interface\n"); + LogPrint(BCLog::ZMQ, "Initialize notification interface\n"); assert(!pcontext); pcontext = zmq_init(1); @@ -91,11 +91,11 @@ bool CZMQNotificationInterface::Initialize() CZMQAbstractNotifier *notifier = *i; if (notifier->Initialize(pcontext)) { - LogPrint("zmq", " Notifier %s ready (address = %s)\n", notifier->GetType(), notifier->GetAddress()); + LogPrint(BCLog::ZMQ, "Notifier %s ready (address = %s)\n", notifier->GetType(), notifier->GetAddress()); } else { - LogPrint("zmq", " Notifier %s failed (address = %s)\n", notifier->GetType(), notifier->GetAddress()); + LogPrint(BCLog::ZMQ, "Notifier %s failed (address = %s)\n", notifier->GetType(), notifier->GetAddress()); break; } } @@ -111,13 +111,13 @@ bool CZMQNotificationInterface::Initialize() // Called during shutdown sequence void CZMQNotificationInterface::Shutdown() { - LogPrint("zmq", "zmq: Shutdown notification interface\n"); + LogPrint(BCLog::ZMQ, "Shutdown notification interface\n"); if (pcontext) { for (std::list::iterator i=notifiers.begin(); i!=notifiers.end(); ++i) { CZMQAbstractNotifier *notifier = *i; - LogPrint("zmq", " Shutdown notifier %s at %s\n", notifier->GetType(), notifier->GetAddress()); + LogPrint(BCLog::ZMQ, "Shutdown notifier %s at %s\n", notifier->GetType(), notifier->GetAddress()); notifier->Shutdown(); } zmq_ctx_destroy(pcontext); diff --git a/src/zmq/zmqpublishnotifier.cpp b/src/zmq/zmqpublishnotifier.cpp index 5d0487e3b2184b..304efaf970fac0 100644 --- a/src/zmq/zmqpublishnotifier.cpp +++ b/src/zmq/zmqpublishnotifier.cpp @@ -87,7 +87,7 @@ bool CZMQAbstractPublishNotifier::Initialize(void *pcontext) } else { - LogPrint("zmq", "zmq: Reusing socket for address %s\n", address); + LogPrint(BCLog::ZMQ, "Reusing socket for address %s\n", address); psocket = i->second->psocket; mapPublishNotifiers.insert(std::make_pair(address, this)); @@ -117,7 +117,7 @@ void CZMQAbstractPublishNotifier::Shutdown() if (count == 1) { - LogPrint("zmq", "Close socket at address %s\n", address); + LogPrint(BCLog::ZMQ, "Close socket at address %s\n", address); int linger = 0; zmq_setsockopt(psocket, ZMQ_LINGER, &linger, sizeof(linger)); zmq_close(psocket); @@ -146,7 +146,7 @@ bool CZMQAbstractPublishNotifier::SendMessage(const char *command, const void* d bool CZMQPublishHashBlockNotifier::NotifyBlock(const CBlockIndex *pindex) { uint256 hash = pindex->GetBlockHash(); - LogPrint("zmq", "zmq: Publish hashblock %s\n", hash.GetHex()); + LogPrint(BCLog::ZMQ, "Publish hashblock %s\n", hash.GetHex()); char data[32]; for (unsigned int i = 0; i < 32; i++) data[31 - i] = hash.begin()[i]; @@ -156,7 +156,7 @@ bool CZMQPublishHashBlockNotifier::NotifyBlock(const CBlockIndex *pindex) bool CZMQPublishHashTransactionNotifier::NotifyTransaction(const CTransaction &transaction) { uint256 hash = transaction.GetHash(); - LogPrint("zmq", "zmq: Publish hashtx %s\n", hash.GetHex()); + LogPrint(BCLog::ZMQ, "Publish hashtx %s\n", hash.GetHex()); char data[32]; for (unsigned int i = 0; i < 32; i++) data[31 - i] = hash.begin()[i]; @@ -166,7 +166,7 @@ bool CZMQPublishHashTransactionNotifier::NotifyTransaction(const CTransaction &t bool CZMQPublishHashTransactionLockNotifier::NotifyTransactionLock(const CTransaction &transaction) { uint256 hash = transaction.GetHash(); - LogPrint("zmq", "zmq: Publish hashtxlock %s\n", hash.GetHex()); + LogPrint(BCLog::ZMQ, "Publish hashtxlock %s\n", hash.GetHex()); char data[32]; for (unsigned int i = 0; i < 32; i++) data[31 - i] = hash.begin()[i]; @@ -175,7 +175,7 @@ bool CZMQPublishHashTransactionLockNotifier::NotifyTransactionLock(const CTransa bool CZMQPublishRawBlockNotifier::NotifyBlock(const CBlockIndex *pindex) { - LogPrint("zmq", "zmq: Publish rawblock %s\n", pindex->GetBlockHash().GetHex()); + LogPrint(BCLog::ZMQ, "Publish rawblock %s\n", pindex->GetBlockHash().GetHex()); // XX42 const Consensus::Params& consensusParams = Params().GetConsensus(); CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); @@ -198,7 +198,7 @@ bool CZMQPublishRawBlockNotifier::NotifyBlock(const CBlockIndex *pindex) bool CZMQPublishRawTransactionNotifier::NotifyTransaction(const CTransaction &transaction) { uint256 hash = transaction.GetHash(); - LogPrint("zmq", "zmq: Publish rawtx %s\n", hash.GetHex()); + LogPrint(BCLog::ZMQ, "Publish rawtx %s\n", hash.GetHex()); CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); ss << transaction; return SendMessage(MSG_RAWTX, &(*ss.begin()), ss.size()); @@ -207,7 +207,7 @@ bool CZMQPublishRawTransactionNotifier::NotifyTransaction(const CTransaction &tr bool CZMQPublishRawTransactionLockNotifier::NotifyTransactionLock(const CTransaction &transaction) { uint256 hash = transaction.GetHash(); - LogPrint("zmq", "zmq: Publish rawtxlock %s\n", hash.GetHex()); + LogPrint(BCLog::ZMQ, "Publish rawtxlock %s\n", hash.GetHex()); CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); ss << transaction; return SendMessage(MSG_RAWTXLOCK, &(*ss.begin()), ss.size()); diff --git a/src/zpiv/zpivtracker.cpp b/src/zpiv/zpivtracker.cpp index 86c6124ad28e78..4567f2fc4076b3 100644 --- a/src/zpiv/zpivtracker.cpp +++ b/src/zpiv/zpivtracker.cpp @@ -441,7 +441,7 @@ std::set CzPIVTracker::ListMints(bool fUnusedOnly, bool fMatureOnly, std::list listMintsDB = walletdb.ListMintedCoins(); for (auto& mint : listMintsDB) Add(mint); - LogPrint("zero", "%s: added %d zerocoinmints from DB\n", __func__, listMintsDB.size()); + LogPrint(BCLog::LEGACYZC, "%s: added %d zerocoinmints from DB\n", __func__, listMintsDB.size()); std::list listDeterministicDB = walletdb.ListDeterministicMints(); @@ -452,7 +452,7 @@ std::set CzPIVTracker::ListMints(bool fUnusedOnly, bool fMatureOnly, Add(dMint, false, false, zPIVWallet); } delete zPIVWallet; - LogPrint("zero", "%s: added %d dzpiv from DB\n", __func__, listDeterministicDB.size()); + LogPrint(BCLog::LEGACYZC, "%s: added %d dzpiv from DB\n", __func__, listDeterministicDB.size()); } std::vector vOverWrite; diff --git a/src/zpiv/zpivwallet.cpp b/src/zpiv/zpivwallet.cpp index e736f56bce9a1e..2d338d1bfe6964 100644 --- a/src/zpiv/zpivwallet.cpp +++ b/src/zpiv/zpivwallet.cpp @@ -274,7 +274,7 @@ void CzPIVWallet::SyncWithChain(bool fGenerateMintPool) SetMintSeen(bnValue, pindex->nHeight, txHash, denomination); nLastCountUsed = std::max(pMint.second, nLastCountUsed); nCountLastUsed = std::max(nLastCountUsed, nCountLastUsed); - LogPrint("zero", "%s: updated count to %d\n", __func__, nCountLastUsed); + LogPrint(BCLog::LEGACYZC, "%s: updated count to %d\n", __func__, nCountLastUsed); } } } diff --git a/src/zpivchain.cpp b/src/zpivchain.cpp index dcb91f67e0fb99..c99e0a538b6fcc 100644 --- a/src/zpivchain.cpp +++ b/src/zpivchain.cpp @@ -356,7 +356,7 @@ bool TxOutToPublicCoin(const CTxOut& txout, libzerocoin::PublicCoin& pubCoin, CV publicZerocoin.setvch(vchZeroMint); libzerocoin::CoinDenomination denomination = libzerocoin::AmountToZerocoinDenomination(txout.nValue); - LogPrint("zero", "%s ZCPRINT denomination %d pubcoin %s\n", __func__, denomination, publicZerocoin.GetHex()); + LogPrint(BCLog::LEGACYZC, "%s : denomination %d for pubcoin %s\n", __func__, denomination, publicZerocoin.GetHex()); if (denomination == libzerocoin::ZQ_ERROR) return state.DoS(100, error("TxOutToPublicCoin : txout.nValue is not correct"));