Browse Source

Merge branch 'subcent-change' of https://github.com/tcatm/bitcoin

0.8
Gavin Andresen 14 years ago
parent
commit
dfd059173d
  1. 24
      main.cpp

24
main.cpp

@ -3759,16 +3759,16 @@ bool SelectCoinsMinConf(int64 nTargetValue, int nConfMine, int nConfTheirs, set<
int64 n = pcoin->GetCredit(); int64 n = pcoin->GetCredit();
if (n <= 0) if (n <= 0)
continue; continue;
if (n < nTargetValue) if (n == nTargetValue)
{
vValue.push_back(make_pair(n, pcoin));
nTotalLower += n;
}
else if (n == nTargetValue)
{ {
setCoinsRet.insert(pcoin); setCoinsRet.insert(pcoin);
return true; return true;
} }
else if (n < nTargetValue + CENT)
{
vValue.push_back(make_pair(n, pcoin));
nTotalLower += n;
}
else if (n < nLowestLarger) else if (n < nLowestLarger)
{ {
nLowestLarger = n; nLowestLarger = n;
@ -3777,7 +3777,14 @@ bool SelectCoinsMinConf(int64 nTargetValue, int nConfMine, int nConfTheirs, set<
} }
} }
if (nTotalLower < nTargetValue) if (nTotalLower == nTargetValue || nTotalLower == nTargetValue + CENT)
{
for (int i = 0; i < vValue.size(); ++i)
setCoinsRet.insert(vValue[i].second);
return true;
}
if (nTotalLower < nTargetValue + (pcoinLowestLarger ? CENT : 0))
{ {
if (pcoinLowestLarger == NULL) if (pcoinLowestLarger == NULL)
return false; return false;
@ -3785,6 +3792,9 @@ bool SelectCoinsMinConf(int64 nTargetValue, int nConfMine, int nConfTheirs, set<
return true; return true;
} }
if (nTotalLower >= nTargetValue + CENT)
nTargetValue += CENT;
// Solve subset sum by stochastic approximation // Solve subset sum by stochastic approximation
sort(vValue.rbegin(), vValue.rend()); sort(vValue.rbegin(), vValue.rend());
vector<char> vfIncluded; vector<char> vfIncluded;

Loading…
Cancel
Save