Skip to content

Commit fd2ca98

Browse files
committed
[Model] Cached cold staking delegations, counting every p2cs record and not only delegation records + update cachedDelegations list using object reference.
1 parent 6298ca8 commit fd2ca98

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/qt/transactiontablemodel.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,8 @@ class TransactionTablePriv
160160
}
161161

162162
// Check for delegations
163-
if (record.type == TransactionRecord::P2CSDelegation || record.type == TransactionRecord::P2CSDelegationSent) {
163+
if (record.type == TransactionRecord::P2CSDelegation || record.type == TransactionRecord::P2CSDelegationSent
164+
|| record.type == TransactionRecord::StakeDelegated || record.type == TransactionRecord::StakeHot) {
164165
checkForDelegations(record, wallet, cachedDelegations);
165166
}
166167
}
@@ -177,7 +178,7 @@ class TransactionTablePriv
177178

178179
static void checkForDelegations(const TransactionRecord& record, const CWallet* wallet, QList<CSDelegation>& cachedDelegations) {
179180
CSDelegation delegation(false, record.address);
180-
delegation.isSpendable = record.type == TransactionRecord::P2CSDelegationSent;
181+
delegation.isSpendable = record.type == TransactionRecord::P2CSDelegationSent || record.type == TransactionRecord::StakeDelegated;
181182

182183
// Append only stakeable utxo and not every output of the record
183184
const QString& hashTxId = record.getTxID();
@@ -208,7 +209,7 @@ class TransactionTablePriv
208209
if (index == -1) {
209210
cachedDelegations.append(delegation);
210211
} else {
211-
CSDelegation del = cachedDelegations[index];
212+
CSDelegation& del = cachedDelegations[index];
212213
del.delegatedUtxo.unite(delegation.delegatedUtxo);
213214
del.cachedTotalAmount += delegation.cachedTotalAmount;
214215
}
@@ -291,7 +292,8 @@ class TransactionTablePriv
291292
if (!hasZcTxes) hasZcTxes = HasZcTxesIfNeeded(rec);
292293

293294
// Check for delegations
294-
if (rec.type == TransactionRecord::P2CSDelegation || rec.type == TransactionRecord::P2CSDelegationSent) {
295+
if (rec.type == TransactionRecord::P2CSDelegation || rec.type == TransactionRecord::P2CSDelegationSent
296+
|| rec.type == TransactionRecord::StakeDelegated || rec.type == TransactionRecord::StakeHot) {
295297
checkForDelegations(rec, wallet, cachedDelegations);
296298
}
297299

0 commit comments

Comments
 (0)