@@ -229,6 +229,7 @@ void CPrivateSendServer::ProcessMessage(CNode* pfrom, std::string& strCommand, C
229
229
230
230
PoolMessage nMessageID = MSG_NOERR;
231
231
232
+ entry.addr = pfrom->addr ;
232
233
if (AddEntry (entry, nMessageID)) {
233
234
PushStatus (pfrom, STATUS_ACCEPTED, nMessageID);
234
235
CheckPool ();
@@ -795,10 +796,21 @@ bool CPrivateSendServer::AddUserToExistingSession(int nDenom, CTransaction txCol
795
796
796
797
void CPrivateSendServer::RelayFinalTransaction (const CTransaction& txFinal)
797
798
{
798
- g_connman->ForEachNode ([&txFinal, this ](CNode* pnode) {
799
- if (pnode->nVersion >= MIN_PRIVATESEND_PEER_PROTO_VERSION)
799
+ LogPrint (" privatesend" , " CPrivateSendServer::%s -- nSessionID: %d nSessionDenom: %d (%s)\n " ,
800
+ __func__, nSessionID, nSessionDenom, CPrivateSend::GetDenominationsToString (nSessionDenom));
801
+
802
+ // final mixing tx with empty signatures should be relayed to mixing participants only
803
+ for (const auto entry : vecEntries) {
804
+ bool fOk = g_connman->ForNode (entry.addr , [&txFinal, this ](CNode* pnode) {
800
805
pnode->PushMessage (NetMsgType::DSFINALTX, nSessionID, txFinal);
801
- });
806
+ return true ;
807
+ });
808
+ if (!fOk ) {
809
+ // no such node? maybe this client disconnected or our own connection went down
810
+ RelayStatus (STATUS_REJECTED);
811
+ break ;
812
+ }
813
+ }
802
814
}
803
815
804
816
void CPrivateSendServer::PushStatus (CNode* pnode, PoolStatusUpdate nStatusUpdate, PoolMessage nMessageID)
@@ -809,18 +821,57 @@ void CPrivateSendServer::PushStatus(CNode* pnode, PoolStatusUpdate nStatusUpdate
809
821
810
822
void CPrivateSendServer::RelayStatus (PoolStatusUpdate nStatusUpdate, PoolMessage nMessageID)
811
823
{
812
- g_connman->ForEachNode ([nStatusUpdate, nMessageID, this ](CNode* pnode) {
813
- if (pnode->nVersion >= MIN_PRIVATESEND_PEER_PROTO_VERSION)
824
+ unsigned int nDisconnected{};
825
+ // status updates should be relayed to mixing participants only
826
+ for (const auto entry : vecEntries) {
827
+ // make sure everyone is still connected
828
+ bool fOk = g_connman->ForNode (entry.addr , [&nStatusUpdate, &nMessageID, this ](CNode* pnode) {
814
829
PushStatus (pnode, nStatusUpdate, nMessageID);
815
- });
830
+ return true ;
831
+ });
832
+ if (!fOk ) {
833
+ // no such node? maybe this client disconnected or our own connection went down
834
+ ++nDisconnected;
835
+ }
836
+ }
837
+ if (nDisconnected == 0 ) return ; // all is clear
838
+
839
+ // smth went wrong
840
+ LogPrintf (" CPrivateSendServer::%s -- can't continue, %llu client(s) disconnected, nSessionID: %d nSessionDenom: %d (%s)\n " ,
841
+ __func__, nDisconnected, nSessionID, nSessionDenom, CPrivateSend::GetDenominationsToString (nSessionDenom));
842
+
843
+ // notify everyone else that this session should be terminated
844
+ for (const auto entry : vecEntries) {
845
+ g_connman->ForNode (entry.addr , [this ](CNode* pnode) {
846
+ PushStatus (pnode, STATUS_REJECTED, MSG_NOERR);
847
+ return true ;
848
+ });
849
+ }
850
+
851
+ if (nDisconnected == vecEntries.size ()) {
852
+ // all clients disconnected, there is probably some issues with our own connection
853
+ // do not charge any fees, just reset the pool
854
+ SetNull ();
855
+ }
816
856
}
817
857
818
858
void CPrivateSendServer::RelayCompletedTransaction (PoolMessage nMessageID)
819
859
{
820
- g_connman->ForEachNode ([nMessageID, this ](CNode* pnode) {
821
- if (pnode->nVersion >= MIN_PRIVATESEND_PEER_PROTO_VERSION)
860
+ LogPrint (" privatesend" , " CPrivateSendServer::%s -- nSessionID: %d nSessionDenom: %d (%s)\n " ,
861
+ __func__, nSessionID, nSessionDenom, CPrivateSend::GetDenominationsToString (nSessionDenom));
862
+
863
+ // final mixing tx with empty signatures should be relayed to mixing participants only
864
+ for (const auto entry : vecEntries) {
865
+ bool fOk = g_connman->ForNode (entry.addr , [&nMessageID, this ](CNode* pnode) {
822
866
pnode->PushMessage (NetMsgType::DSCOMPLETE, nSessionID, (int )nMessageID);
823
- });
867
+ return true ;
868
+ });
869
+ if (!fOk ) {
870
+ // no such node? maybe client disconnected or our own connection went down
871
+ RelayStatus (STATUS_REJECTED);
872
+ break ;
873
+ }
874
+ }
824
875
}
825
876
826
877
void CPrivateSendServer::SetState (PoolState nStateNew)
0 commit comments