Skip to content

Commit

Permalink
More fixes for PrivateSend after 2612 (#2614)
Browse files Browse the repository at this point in the history
* Fix CPrivateSendServer::IsSessionReady()

Also move it to cpp

* Make sure nSessionMaxParticipants is initialized properly

* Adjust logging

* adjust log a bit more
  • Loading branch information
UdjinM6 committed Jan 8, 2019
1 parent bade332 commit fa18d3e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
15 changes: 10 additions & 5 deletions src/privatesend-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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",
Expand Down
6 changes: 4 additions & 2 deletions src/privatesend-server.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class CPrivateSendServer : public CPrivateSendBaseSession, public CPrivateSendBa
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();
Expand All @@ -70,7 +70,9 @@ class CPrivateSendServer : public CPrivateSendBaseSession, public CPrivateSendBa

public:
CPrivateSendServer() :
vecSessionCollaterals(), fUnitTest(false) {}
vecSessionCollaterals(),
nSessionMaxParticipants(0),
fUnitTest(false) {}

void ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStream& vRecv, CConnman& connman);

Expand Down

0 comments on commit fa18d3e

Please sign in to comment.