Dash Core  0.12.2.1
P2P Digital Currency
privatesend-server.h
Go to the documentation of this file.
1 // Copyright (c) 2014-2017 The Dash Core developers
2 // Distributed under the MIT/X11 software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #ifndef PRIVATESENDSERVER_H
6 #define PRIVATESENDSERVER_H
7 
8 #include "net.h"
9 #include "privatesend.h"
10 
11 class CPrivateSendServer;
12 
13 // The main object for accessing mixing
15 
19 {
20 private:
22 
23  // Mixing uses collateral transactions to trust parties entering the pool
24  // to behave honestly. If they don't it takes their money.
25  std::vector<CTransaction> vecSessionCollaterals;
26 
27  bool fUnitTest;
28 
30  bool AddEntry(const CDarkSendEntry& entryNew, PoolMessage& nMessageIDRet);
32  bool AddScriptSig(const CTxIn& txin);
33 
35  void ChargeFees(CConnman& connman);
37  void ChargeRandomFees(CConnman& connman);
38 
40  void CheckPool(CConnman& connman);
41 
42  void CreateFinalTransaction(CConnman& connman);
43  void CommitFinalTransaction(CConnman& connman);
44 
46  bool IsAcceptableDenomAndCollateral(int nDenom, CTransaction txCollateral, PoolMessage &nMessageIDRet);
47  bool CreateNewSession(int nDenom, CTransaction txCollateral, PoolMessage &nMessageIDRet, CConnman& connman);
48  bool AddUserToExistingSession(int nDenom, CTransaction txCollateral, PoolMessage &nMessageIDRet);
51 
53  bool IsSignaturesComplete();
55  bool IsInputScriptSigValid(const CTxIn& txin);
57  bool IsOutputsCompatibleWithSessionDenom(const std::vector<CTxDSOut>& vecTxDSOut);
58 
59  // Set the 'state' value, with some logging and capturing when the state changed
60  void SetState(PoolState nStateNew);
61 
63  void RelayFinalTransaction(const CTransaction& txFinal, CConnman& connman);
64  void PushStatus(CNode* pnode, PoolStatusUpdate nStatusUpdate, PoolMessage nMessageID, CConnman& connman);
65  void RelayStatus(PoolStatusUpdate nStatusUpdate, CConnman& connman, PoolMessage nMessageID = MSG_NOERR);
66  void RelayCompletedTransaction(PoolMessage nMessageID, CConnman& connman);
67 
68  void SetNull();
69 
70 public:
72  fUnitTest(false) { SetNull(); }
73 
74  void ProcessMessage(CNode* pfrom, std::string& strCommand, CDataStream& vRecv, CConnman& connman);
75 
76  void CheckTimeout(CConnman& connman);
77  void CheckForCompleteQueue(CConnman& connman);
78 };
79 
81 
82 #endif
std::vector< CTransaction > vecSessionCollaterals
void CommitFinalTransaction(CConnman &connman)
bool AddEntry(const CDarkSendEntry &entryNew, PoolMessage &nMessageIDRet)
Add a clients entry to the pool.
Definition: net.h:108
bool IsSessionReady()
Do we have enough users to take entries?
PoolMessage
Definition: privatesend.h:30
void CreateFinalTransaction(CConnman &connman)
bool IsOutputsCompatibleWithSessionDenom(const std::vector< CTxDSOut > &vecTxDSOut)
Are these outputs compatible with other client in the pool?
CCriticalSection cs_darksend
void CheckForCompleteQueue(CConnman &connman)
void ThreadCheckPrivateSendServer(CConnman &connman)
Definition: net.h:661
bool AddScriptSig(const CTxIn &txin)
Add signature to a txin.
void SetState(PoolState nStateNew)
bool AddUserToExistingSession(int nDenom, CTransaction txCollateral, PoolMessage &nMessageIDRet)
void CheckPool(CConnman &connman)
Check for process.
void CheckTimeout(CConnman &connman)
bool IsInputScriptSigValid(const CTxIn &txin)
Check to make sure a given input matches an input in the pool and its scriptSig is valid...
PoolStatusUpdate
Definition: privatesend.h:70
bool CreateNewSession(int nDenom, CTransaction txCollateral, PoolMessage &nMessageIDRet, CConnman &connman)
bool IsAcceptableDenomAndCollateral(int nDenom, CTransaction txCollateral, PoolMessage &nMessageIDRet)
Is this nDenom and txCollateral acceptable?
static int GetMaxPoolTransactions()
Get the maximum number of transactions for the pool.
Definition: privatesend.h:343
PoolState
Definition: privatesend.h:58
void PushStatus(CNode *pnode, PoolStatusUpdate nStatusUpdate, PoolMessage nMessageID, CConnman &connman)
bool IsSignaturesComplete()
Check that all inputs are signed. (Are all inputs signed?)
void ProcessMessage(CNode *pfrom, std::string &strCommand, CDataStream &vRecv, CConnman &connman)
void RelayCompletedTransaction(PoolMessage nMessageID, CConnman &connman)
void ChargeRandomFees(CConnman &connman)
Rarely charge fees to pay miners.
void RelayStatus(PoolStatusUpdate nStatusUpdate, CConnman &connman, PoolMessage nMessageID=MSG_NOERR)
CPrivateSendServer privateSendServer
void ChargeFees(CConnman &connman)
Charge fees to bad actors (Charge clients a fee if they&#39;re abusive)
void RelayFinalTransaction(const CTransaction &txFinal, CConnman &connman)
Relay mixing Messages.