limit scope of cs_wallet in PrepareDarksendDenominate

This commit is contained in:
UdjinM6 2015-08-08 20:01:18 +03:00
parent ec3848c5dd
commit e4677275a2

View File

@ -2434,9 +2434,11 @@ string CWallet::PrepareDarksendDenominate(int minRounds, int maxRounds)
LogPrintf("PrepareDarksendDenominate - preparing darksend denominate . Got: %d \n", nValueIn); LogPrintf("PrepareDarksendDenominate - preparing darksend denominate . Got: %d \n", nValueIn);
{
LOCK(cs_wallet); LOCK(cs_wallet);
BOOST_FOREACH(CTxIn v, vCoins) BOOST_FOREACH(CTxIn v, vCoins)
LockCoin(v.prevout); LockCoin(v.prevout);
}
int64_t nValueLeft = nValueIn; int64_t nValueLeft = nValueIn;
std::vector<CTxOut> vOut; std::vector<CTxOut> vOut;
@ -2503,12 +2505,16 @@ string CWallet::PrepareDarksendDenominate(int minRounds, int maxRounds)
if(nValueLeft == 0) break; if(nValueLeft == 0) break;
} }
{
// unlock unused coins // unlock unused coins
LOCK(cs_wallet);
BOOST_FOREACH(CTxIn v, vCoins) BOOST_FOREACH(CTxIn v, vCoins)
UnlockCoin(v.prevout); UnlockCoin(v.prevout);
}
if(darkSendPool.GetDenominations(vOut) != darkSendPool.sessionDenom) { if(darkSendPool.GetDenominations(vOut) != darkSendPool.sessionDenom) {
// unlock used coins on failure // unlock used coins on failure
LOCK(cs_wallet);
BOOST_FOREACH(CTxIn v, vCoinsResult) BOOST_FOREACH(CTxIn v, vCoinsResult)
UnlockCoin(v.prevout); UnlockCoin(v.prevout);
return "Error: can't make current denominated outputs"; return "Error: can't make current denominated outputs";