Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions src/qt/mintingtablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,21 @@ class MintingTablePriv
return;
}

// append
int offsetLower = 0;
for(const KernelRecord& kr : KernelRecord::decomposeOutput(wtx))
{
if(parent->walletModel->wallet().isSpent(kr.hash, kr.n)) // spent
{
continue;
}

parent->beginInsertRows(QModelIndex(), lowerIndex + offsetLower, lowerIndex + offsetLower);
cachedWallet.insert(lowerIndex + offsetLower, kr);
parent->endInsertRows();
offsetLower++;
}

// spent
const std::vector<CTxIn> ins = wtx.tx->vin;
const std::vector<isminetype> isMine = wtx.txin_is_mine;
Expand All @@ -157,31 +172,16 @@ class MintingTablePriv
uint256 phash = ins[i].prevout.hash;
uint32_t n = ins[i].prevout.n;

for(int i = 0; i < cachedWallet.size(); i++){
if(cachedWallet[i].hash == phash && cachedWallet[i].n == n){
parent->beginRemoveRows(QModelIndex(), i, i);
cachedWallet.removeAt(i);
for(int delIndex = 0; delIndex < cachedWallet.size(); delIndex++){
if(cachedWallet[delIndex].hash == phash && cachedWallet[delIndex].n == n){
parent->beginRemoveRows(QModelIndex(), delIndex, delIndex);
cachedWallet.removeAt(delIndex);
parent->endRemoveRows();
break;
}
}
}
}

// append
int offsetLower = 0;
for(const KernelRecord& kr : KernelRecord::decomposeOutput(wtx))
{
if(parent->walletModel->wallet().isSpent(kr.hash, kr.n)) // spent
{
continue;
}

parent->beginInsertRows(QModelIndex(), lowerIndex + offsetLower, lowerIndex + offsetLower);
cachedWallet.insert(lowerIndex + offsetLower, kr);
parent->endInsertRows();
offsetLower++;
}
}
else if(status == CT_UPDATED)
{
Expand All @@ -193,7 +193,7 @@ class MintingTablePriv
parent->beginRemoveRows(QModelIndex(), lowerIndex, upperIndex - 1);
for(int i = lowerIndex; i < upperIndex; i++)
{
cachedWallet.removeAt(i);
cachedWallet.removeAt(lowerIndex); // don't use i
}
parent->endRemoveRows();

Expand Down