fixed queuing

This commit is contained in:
Evan Duffield 2014-08-11 18:27:23 -07:00
parent 7e9128614b
commit d5d27b78f2
3 changed files with 29 additions and 26 deletions

View File

@ -6854,22 +6854,15 @@ bool CDarkSendPool::GetLastValidBlockHash(uint256& hash, int mod, int nBlockHeig
bool CDarkSendPool::DoConcessusVote(int64 nBlockHeight)
{
LogPrintf("CDarkSendPool::DoConcessusVote\n");
bool fIsInitialDownload = IsInitialBlockDownload();
if(fIsInitialDownload) return false;
LogPrintf("CDarkSendPool::DoConcessusVote - 2\n");
//If masternode, vote for whoever I think should win next block
if(!fMasterNode || isCapableMasterNode != MASTERNODE_IS_CAPABLE) return false;
LogPrintf("CDarkSendPool::DoConcessusVote - 3\n");
int rank = GetMasternodeRank(vinMasterNode, 1);
int winner = GetCurrentMasterNode(1, nBlockHeight);
LogPrintf("CDarkSendPool::DoConcessusVote - 4 %d %d\n", rank, winner);
if(rank <= 10 && winner != 1){
std::vector<unsigned char> vchMasterNodeSignature;
std::string errorMessage = "";
@ -7083,7 +7076,7 @@ bool CDarkSendPool::DoAutomaticDenominating(bool fDryRun)
}
if(balanceNeedsAnonymized > nValueMax) balanceNeedsAnonymized = nValueMax;
if (!pwalletMain->SelectCoinsDark(nValueMin, nValueMax, vCoins, nValueIn, minRounds, nDarksendRounds))
if (!pwalletMain->SelectCoinsDark(nValueMin, maxAmount*COIN, vCoins, nValueIn, minRounds, nDarksendRounds))
{
nValueIn = 0;
vCoins.clear();
@ -7099,6 +7092,7 @@ bool CDarkSendPool::DoAutomaticDenominating(bool fDryRun)
return false;
}
if(nValueIn < COIN*1.1){
//simply look for non-denominated coins
@ -7116,13 +7110,17 @@ bool CDarkSendPool::DoAutomaticDenominating(bool fDryRun)
// initial phase, find a masternode
if(!sessionFoundMasternode){
int64 nTotalValue = pwalletMain->GetTotalValue(vCoins) - DARKSEND_FEE;
double fDarkcoinSubmitted = nTotalValue / COIN;
LogPrintf("Submiting Darksend for %f DRK\n", fDarkcoinSubmitted);
// if we have any pending merges
BOOST_FOREACH(CDarksendQueue dsq, vecDarksendQueue){
CService addr;
if(dsq.time == 0) continue;
if(!dsq.GetAddress(addr)) continue;
if(dsq.nDenom != GetDenominationsByAmount(nValueIn)) {
LogPrintf(" dsq.nDenom != GetDenominationsByAmount %"PRI64d" %d \n", dsq.nDenom, GetDenominationsByAmount(nValueIn));
if(dsq.nDenom != GetDenominationsByAmount(nTotalValue)) {
LogPrintf(" dsq.nDenom != GetDenominationsByAmount %"PRI64d" %d \n", dsq.nDenom, GetDenominationsByAmount(nTotalValue));
continue;
}
dsq.time = 0; //remove node
@ -7133,8 +7131,8 @@ bool CDarkSendPool::DoAutomaticDenominating(bool fDryRun)
BOOST_FOREACH(CNode* pnode, vNodes)
{
if(submittedToMasternode != pnode->addr) continue;
pnode->PushMessage("dsa", nValueIn);
LogPrintf("DoAutomaticDenominating --- connected (from queue), sending dsa for %"PRI64d"\n", balanceNeedsAnonymized);
pnode->PushMessage("dsa", nTotalValue);
LogPrintf("DoAutomaticDenominating --- connected (from queue), sending dsa for %"PRI64d"\n", nTotalValue);
return true;
}
} else {
@ -7158,8 +7156,8 @@ bool CDarkSendPool::DoAutomaticDenominating(bool fDryRun)
BOOST_FOREACH(CNode* pnode, vNodes)
{
if(darkSendMasterNodes[i].addr != pnode->addr) continue;
pnode->PushMessage("dsa", balanceNeedsAnonymized);
LogPrintf("DoAutomaticDenominating --- connected, sending dsa for %"PRI64d"\n", balanceNeedsAnonymized);
pnode->PushMessage("dsa", nTotalValue);
LogPrintf("DoAutomaticDenominating --- connected, sending dsa for %"PRI64d"\n", nTotalValue);
return true;
}
} else {

View File

@ -1678,6 +1678,21 @@ string CWallet::SendMoneyToDestination(const CTxDestination& address, int64 nVal
return SendMoney(scriptPubKey, nValue, wtxNew, fAskFee, coin_type);
}
int64 CWallet::GetTotalValue(std::vector<CTxIn> vCoins) {
int64 nTotalValue = 0;
CWalletTx wtx;
BOOST_FOREACH(CTxIn i, vCoins){
if (mapWallet.count(i.prevout.hash))
{
CWalletTx& wtx = mapWallet[i.prevout.hash];
nTotalValue += wtx.vout[i.prevout.n].nValue;
} else {
LogPrintf("GetTotalValue -- Couldn't find transaction\n");
}
}
return nTotalValue;
}
string CWallet::DarkSendDenominate(int minRounds, int maxAmount)
{
@ -1709,18 +1724,7 @@ string CWallet::DarkSendDenominate(int minRounds, int maxAmount)
}
// calculate total value out
int64 nTotalValue = 0;
CWalletTx wtx;
BOOST_FOREACH(CTxIn i, vCoins){
if (mapWallet.count(i.prevout.hash))
{
CWalletTx& wtx = mapWallet[i.prevout.hash];
nTotalValue += wtx.vout[i.prevout.n].nValue;
} else {
LogPrintf("SelectCoinsDarkDenominated -- Couldn't find transaction\n");
}
}
nTotalValue -= nFeeRet; //minus fees
int64 nTotalValue = GetTotalValue(vCoins) - nFeeRet;
//--------------

View File

@ -146,6 +146,7 @@ public:
void UnlockCoin(COutPoint& output);
void UnlockAllCoins();
void ListLockedCoins(std::vector<COutPoint>& vOutpts);
int64 GetTotalValue(std::vector<CTxIn> vCoins);
// keystore implementation
// Generate a new key