MCPcopy Create free account
hub / github.com/LUX-Core/lux / IsCompatibleWithSession

Method IsCompatibleWithSession

src/darksend.cpp:1799–1850  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1797}
1798
1799bool CDarkSendPool::IsCompatibleWithSession(int64_t nDenom, CTransaction txCollateral, std::string& strReason) {
1800 LogPrintf("CDarkSendPool::IsCompatibleWithSession - sessionDenom %d sessionUsers %d\n", sessionDenom, sessionUsers);
1801
1802 if (!unitTest && !IsCollateralValid(txCollateral)) {
1803 if (fDebug) LogPrintf ("CDarkSendPool::IsCompatibleWithSession - collateral not valid!\n");
1804 strReason = _("Collateral not valid.");
1805 return false;
1806 }
1807
1808 if (sessionUsers < 0) sessionUsers = 0;
1809
1810 if (sessionUsers == 0) {
1811 sessionDenom = nDenom;
1812 sessionUsers++;
1813 lastTimeChanged = GetTimeMillis();
1814 entries.clear();
1815
1816 if (!unitTest) {
1817 //broadcast that I'm accepting entries, only if it's the first entry though
1818 CDarksendQueue dsq;
1819 dsq.nDenom = nDenom;
1820 dsq.vin = activeMasternode.vin;
1821 dsq.time = GetTime();
1822 dsq.Sign();
1823 dsq.Relay();
1824 }
1825
1826 UpdateState(POOL_STATUS_QUEUE);
1827 vecSessionCollateral.push_back(txCollateral);
1828 return true;
1829 }
1830
1831 if ((state != POOL_STATUS_ACCEPTING_ENTRIES && state != POOL_STATUS_QUEUE) || sessionUsers >= GetMaxPoolTransactions()) {
1832 if ((state != POOL_STATUS_ACCEPTING_ENTRIES && state != POOL_STATUS_QUEUE)) strReason = _("Incompatible mode.");
1833 if (sessionUsers >= GetMaxPoolTransactions()) strReason = _("Masternode queue is full.");
1834 LogPrintf("CDarkSendPool::IsCompatibleWithSession - incompatible mode, return false %d %d\n", state != POOL_STATUS_ACCEPTING_ENTRIES, sessionUsers >= GetMaxPoolTransactions());
1835 return false;
1836 }
1837
1838 if (nDenom != sessionDenom) {
1839 strReason = _("No matching denominations found for mixing.");
1840 return false;
1841 }
1842
1843 LogPrintf("CDarkSendPool::IsCompatibleWithSession - compatible\n");
1844
1845 sessionUsers++;
1846 lastTimeChanged = GetTimeMillis();
1847 vecSessionCollateral.push_back(txCollateral);
1848
1849 return true;
1850}
1851
1852//create a nice string to show the denominations
1853void CDarkSendPool::GetDenominationsToString(int nDenom, std::string& strDenom) {

Callers 1

ProcessMessageDarksendFunction · 0.80

Calls 7

_Function · 0.85
GetTimeMillisFunction · 0.85
GetTimeFunction · 0.85
clearMethod · 0.45
SignMethod · 0.45
RelayMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected