@@ -152,16 +152,7 @@ class TransactionTablePriv
152152
153153 // Check for delegations
154154 if (record.type == TransactionRecord::P2CSDelegation) {
155- CSDelegation delegation (false , record.address );
156- delegation.cachedTotalAmount += record.credit ;
157- int index = cachedDelegations.indexOf (delegation);
158- if (index == -1 ) {
159- cachedDelegations.append (delegation);
160- } else {
161- CSDelegation del = cachedDelegations[index];
162- del.delegatedUtxo .append (record.getTxID ());
163- del.cachedTotalAmount += record.credit ;
164- }
155+ checkForDelegations (record, cachedDelegations);
165156 }
166157 }
167158
@@ -175,6 +166,20 @@ class TransactionTablePriv
175166 return std::make_pair (cachedWallet, cachedDelegations);
176167 }
177168
169+ static void checkForDelegations (const TransactionRecord& record, QList<CSDelegation>& cachedDelegations) {
170+ CSDelegation delegation (false , record.address );
171+ delegation.cachedTotalAmount += record.credit ;
172+ int index = cachedDelegations.indexOf (delegation);
173+ if (index == -1 ) {
174+ cachedDelegations.append (delegation);
175+ } else {
176+ CSDelegation del = cachedDelegations[index];
177+ del.delegatedUtxo .append (record.getTxID ());
178+ del.cachedTotalAmount += record.credit ;
179+ }
180+
181+ }
182+
178183 static bool HasZcTxesIfNeeded (const TransactionRecord& record) {
179184 return (record.type == TransactionRecord::ZerocoinMint ||
180185 record.type == TransactionRecord::ZerocoinSpend ||
@@ -235,6 +240,12 @@ class TransactionTablePriv
235240 for (const TransactionRecord& rec : toInsert) {
236241 cachedWallet.insert (insert_idx, rec);
237242 if (!hasZcTxes) hasZcTxes = HasZcTxesIfNeeded (rec);
243+
244+ // Check for delegations
245+ if (rec.type == TransactionRecord::P2CSDelegation) {
246+ checkForDelegations (rec, cachedDelegations);
247+ }
248+
238249 insert_idx += 1 ;
239250 // Return record
240251 ret = rec;
0 commit comments