Further improvements to the matching engine

This commit is contained in:
Evan Duffield 2014-12-30 15:42:50 -07:00
parent 80144a47ab
commit a290bc06f2
3 changed files with 22 additions and 2 deletions

View File

@ -1976,7 +1976,7 @@ int CDarkSendPool::GetDenominationsByAmounts(std::vector<int64_t>& vecAmount){
return GetDenominations(vout1);
}
int CDarkSendPool::GetDenominationsByAmount(int64_t nAmount){
int CDarkSendPool::GetDenominationsByAmount(int64_t nAmount, int nDenomTarget){
CScript e = CScript();
int64_t nValueLeft = nAmount;
@ -1984,6 +1984,15 @@ int CDarkSendPool::GetDenominationsByAmount(int64_t nAmount){
// Make outputs by looping through denominations, from small to large
BOOST_REVERSE_FOREACH(int64_t v, darkSendDenominations){
if(nDenomTarget != 0){
bool fAccepted = false;
if((nDenomTarget & (1 << 0)) && v == ((100*COIN)+1)) {fAccepted = true;}
else if((nDenomTarget & (1 << 1)) && v == ((10*COIN)+1)) {fAccepted = true;}
else if((nDenomTarget & (1 << 2)) && v == ((1*COIN)+1)) {fAccepted = true;}
else if((nDenomTarget & (1 << 3)) && v == ((.1*COIN)+1)) {fAccepted = true;}
if(!fAccepted) continue;
}
int nOutputs = 0;
if(std::find(vecDisabledDenominations.begin(), vecDisabledDenominations.end(), v) != vecDisabledDenominations.end())

View File

@ -431,7 +431,8 @@ public:
int GetDenominations(const std::vector<CTxOut>& vout);
void GetDenominationsToString(int nDenom, std::string& strDenom);
// get the denominations for a specific amount of darkcoin.
int GetDenominationsByAmount(int64_t nAmount);
int GetDenominationsByAmount(int64_t nAmount, int nDenomTarget=0);
int GetDenominationsByAmounts(std::vector<int64_t>& vecAmount);
};

View File

@ -1452,6 +1452,16 @@ struct CompareByPriority
bool CWallet::SelectCoinsByDenominations(int nDenom, int64_t nValueMin, int64_t nValueMax, std::vector<CTxIn>& setCoinsRet, int64_t& nValueRet, int nDarksendRoundsMin, int nDarksendRoundsMax)
{
//if the forth bit is on, it doesn't matter which inputs we chose
if(nDenom & (1 << 4)) {
if(SelectCoinsDark(nValueMin, nValueMax, setCoinsRet, nValueRet, nDarksendRoundsMin, nDarksendRoundsMax)){
int64_t nTotalValue = GetTotalValue(setCoinsRet);
return nDenom == darkSendPool.GetDenominationsByAmount(nTotalValue, nDenom);
} else {
return false;
}
}
CCoinControl *coinControl=NULL;
setCoinsRet.clear();