From fa18d3e1029abc697453cc93196b703c4a2990a6 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Tue, 8 Jan 2019 13:36:12 +0300 Subject: [PATCH] More fixes for PrivateSend after 2612 (#2614) * Fix CPrivateSendServer::IsSessionReady() Also move it to cpp * Make sure nSessionMaxParticipants is initialized properly * Adjust logging * adjust log a bit more --- src/privatesend-server.cpp | 15 ++++++++++----- src/privatesend-server.h | 6 ++++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/privatesend-server.cpp b/src/privatesend-server.cpp index cc328e548..ed74f83bc 100644 --- a/src/privatesend-server.cpp +++ b/src/privatesend-server.cpp @@ -615,7 +615,7 @@ bool CPrivateSendServer::AddEntry(const CPrivateSendEntry& entryNew, PoolMessage vecEntries.push_back(entryNew); - LogPrint("privatesend", "CPrivateSendServer::AddEntry -- adding entry\n"); + LogPrint("privatesend", "CPrivateSendServer::AddEntry -- adding entry %d of %d required\n", GetEntriesCount(), nSessionMaxParticipants); nMessageIDRet = MSG_ENTRIES_ADDED; nTimeLastSuccessfulStep = GetTime(); @@ -738,8 +738,8 @@ bool CPrivateSendServer::CreateNewSession(const CPrivateSendAccept& dsa, PoolMes } vecSessionCollaterals.push_back(MakeTransactionRef(dsa.txCollateral)); - LogPrintf("CPrivateSendServer::CreateNewSession -- new session created, nSessionID: %d nSessionDenom: %d (%s) vecSessionCollaterals.size(): %d\n", - nSessionID, nSessionDenom, CPrivateSend::GetDenominationsToString(nSessionDenom), vecSessionCollaterals.size()); + LogPrintf("CPrivateSendServer::CreateNewSession -- new session created, nSessionID: %d nSessionDenom: %d (%s) vecSessionCollaterals.size(): %d nSessionMaxParticipants: %d\n", + nSessionID, nSessionDenom, CPrivateSend::GetDenominationsToString(nSessionDenom), vecSessionCollaterals.size(), nSessionMaxParticipants); return true; } @@ -772,12 +772,17 @@ bool CPrivateSendServer::AddUserToExistingSession(const CPrivateSendAccept& dsa, nTimeLastSuccessfulStep = GetTime(); vecSessionCollaterals.push_back(MakeTransactionRef(dsa.txCollateral)); - LogPrintf("CPrivateSendServer::AddUserToExistingSession -- new user accepted, nSessionID: %d nSessionDenom: %d (%s) vecSessionCollaterals.size(): %d\n", - nSessionID, nSessionDenom, CPrivateSend::GetDenominationsToString(nSessionDenom), vecSessionCollaterals.size()); + LogPrintf("CPrivateSendServer::AddUserToExistingSession -- new user accepted, nSessionID: %d nSessionDenom: %d (%s) vecSessionCollaterals.size(): %d nSessionMaxParticipants: %d\n", + nSessionID, nSessionDenom, CPrivateSend::GetDenominationsToString(nSessionDenom), vecSessionCollaterals.size(), nSessionMaxParticipants); return true; } +bool CPrivateSendServer::IsSessionReady() +{ + return nSessionMaxParticipants != 0 && (int)vecSessionCollaterals.size() >= nSessionMaxParticipants; +} + void CPrivateSendServer::RelayFinalTransaction(const CTransaction& txFinal, CConnman& connman) { LogPrint("privatesend", "CPrivateSendServer::%s -- nSessionID: %d nSessionDenom: %d (%s)\n", diff --git a/src/privatesend-server.h b/src/privatesend-server.h index 5b098d0a9..4e654e853 100644 --- a/src/privatesend-server.h +++ b/src/privatesend-server.h @@ -48,7 +48,7 @@ private: bool CreateNewSession(const CPrivateSendAccept& dsa, PoolMessage& nMessageIDRet, CConnman& connman); bool AddUserToExistingSession(const CPrivateSendAccept& dsa, PoolMessage& nMessageIDRet); /// Do we have enough users to take entries? - bool IsSessionReady() { return (int)vecSessionCollaterals.size() >= nSessionMaxParticipants; } + bool IsSessionReady(); /// Check that all inputs are signed. (Are all inputs signed?) bool IsSignaturesComplete(); @@ -70,7 +70,9 @@ private: public: CPrivateSendServer() : - vecSessionCollaterals(), fUnitTest(false) {} + vecSessionCollaterals(), + nSessionMaxParticipants(0), + fUnitTest(false) {} void ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStream& vRecv, CConnman& connman);