Skip to content

Commit

Permalink
Fix minting table update.
Browse files Browse the repository at this point in the history
  • Loading branch information
glv2 authored and MitchellCash committed Feb 19, 2016
1 parent aab3258 commit 1726180
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 31 deletions.
7 changes: 1 addition & 6 deletions src/kernelrecord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ bool KernelRecord::showTransaction(const CWalletTx &wtx)
}
}

if(!wtx.IsConfirmed())
{
return false;
}

return true;
}

Expand Down Expand Up @@ -56,7 +51,7 @@ vector<KernelRecord> KernelRecord::decomposeOutput(const CWallet *wallet, const
addrStr = mapValue["to"];
}

parts.push_back(KernelRecord(hash, nTime, addrStr, txOut.nValue, wtx.IsSpent(nOut), coinAge));
parts.push_back(KernelRecord(hash, nTime, addrStr, txOut.nValue, nOut, wtx.IsSpent(nOut), coinAge));
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/kernelrecord.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ class KernelRecord

KernelRecord(uint256 hash, int64 nTime,
const std::string &address,
int64 nValue, bool spent, int64 coinAge):
int64 nValue, int idx, bool spent, int64 coinAge):
hash(hash), nTime(nTime), address(address), nValue(nValue),
idx(0), spent(spent), coinAge(coinAge), prevMinutes(0), prevDifficulty(0), prevProbability(0)
idx(idx), spent(spent), coinAge(coinAge), prevMinutes(0), prevDifficulty(0), prevProbability(0)
{
}

Expand Down
39 changes: 16 additions & 23 deletions src/qt/mintingtablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,16 +133,16 @@ class MintingTablePriv
KernelRecord::decomposeOutput(wallet, mi->second);
if(!toInsert.empty()) /* only if something to insert */
{
parent->beginInsertRows(QModelIndex(), lowerIndex, lowerIndex+toInsert.size()-1);
int insert_idx = lowerIndex;
BOOST_FOREACH(const KernelRecord &rec, toInsert)
{
if(!rec.spent) {
parent->beginInsertRows(QModelIndex(), insert_idx, insert_idx);
cachedWallet.insert(insert_idx, rec);
insert_idx += 1;
parent->endInsertRows();
}
}
parent->endInsertRows();
}
}
else if(!inWallet && inModel)
Expand All @@ -156,21 +156,24 @@ class MintingTablePriv
{
// Updated -- remove spent coins from table
std::vector<KernelRecord> toCheck = KernelRecord::decomposeOutput(wallet, mi->second);
BOOST_FOREACH(const KernelRecord &rec, toCheck)
if(!toCheck.empty())
{
if(rec.spent)
BOOST_FOREACH(const KernelRecord &rec, toCheck)
{
for(int i = 0; i < cachedWallet.size(); i++)
if(rec.spent)
{
KernelRecord cachedRec = cachedWallet.at(i);
if((rec.hash == cachedRec.hash)
&& (rec.nTime == cachedRec.nTime)
&& (rec.nValue == cachedRec.nValue))
for(int i = lowerIndex; i < upperIndex; i++)
{
parent->beginRemoveRows(QModelIndex(), i, i);
cachedWallet.removeAt(i);
parent->endRemoveRows();
break;
KernelRecord cachedRec = cachedWallet.at(i);
if((rec.address == cachedRec.address)
&& (rec.nValue == cachedRec.nValue)
&& (rec.idx == cachedRec.idx))
{
parent->beginRemoveRows(QModelIndex(), i, i);
cachedWallet.removeAt(i);
parent->endRemoveRows();
break;
}
}
}
}
Expand Down Expand Up @@ -246,16 +249,6 @@ void MintingTableModel::update()
BOOST_FOREACH(uint256 hash, wallet->vMintingWalletUpdated)
{
updated.append(hash);

// Also check the inputs to remove spent outputs from the table if necessary
CWalletTx wtx;
if(wallet->GetTransaction(hash, wtx))
{
BOOST_FOREACH(const CTxIn& txin, wtx.vin)
{
updated.append(txin.prevout.hash);
}
}
}
wallet->vMintingWalletUpdated.clear();
}
Expand Down

0 comments on commit 1726180

Please sign in to comment.