@@ -623,8 +623,9 @@ void CWallet::AddToSpends(const COutPoint& outpoint, const uint256& wtxid)
623
623
624
624
void CWallet::AddToSpends (const uint256& wtxid)
625
625
{
626
- assert (mapWallet.count (wtxid));
627
- CWalletTx& thisTx = mapWallet[wtxid];
626
+ auto it = mapWallet.find (wtxid);
627
+ assert (it != mapWallet.end ());
628
+ CWalletTx& thisTx = it->second ;
628
629
if (thisTx.IsCoinBase ()) // Coinbases don't spend anything!
629
630
return ;
630
631
@@ -1007,8 +1008,9 @@ bool CWallet::LoadToWallet(const CWalletTx& wtxIn)
1007
1008
wtxOrdered.insert (std::make_pair (wtx.nOrderPos , TxPair (&wtx, nullptr )));
1008
1009
AddToSpends (hash);
1009
1010
for (const CTxIn& txin : wtx.tx ->vin ) {
1010
- if (mapWallet.count (txin.prevout .hash )) {
1011
- CWalletTx& prevtx = mapWallet[txin.prevout .hash ];
1011
+ auto it = mapWallet.find (txin.prevout .hash );
1012
+ if (it != mapWallet.end ()) {
1013
+ CWalletTx& prevtx = it->second ;
1012
1014
if (prevtx.nIndex == -1 && !prevtx.hashUnset ()) {
1013
1015
MarkConflicted (prevtx.hashBlock , wtx.GetHash ());
1014
1016
}
@@ -1107,8 +1109,9 @@ bool CWallet::AbandonTransaction(const uint256& hashTx)
1107
1109
std::set<uint256> done;
1108
1110
1109
1111
// Can't mark abandoned if confirmed or in mempool
1110
- assert (mapWallet.count (hashTx));
1111
- CWalletTx& origtx = mapWallet[hashTx];
1112
+ auto it = mapWallet.find (hashTx);
1113
+ assert (it != mapWallet.end ());
1114
+ CWalletTx& origtx = it->second ;
1112
1115
if (origtx.GetDepthInMainChain () > 0 || origtx.InMempool ()) {
1113
1116
return false ;
1114
1117
}
@@ -1119,8 +1122,9 @@ bool CWallet::AbandonTransaction(const uint256& hashTx)
1119
1122
uint256 now = *todo.begin ();
1120
1123
todo.erase (now);
1121
1124
done.insert (now);
1122
- assert (mapWallet.count (now));
1123
- CWalletTx& wtx = mapWallet[now];
1125
+ auto it = mapWallet.find (now);
1126
+ assert (it != mapWallet.end ());
1127
+ CWalletTx& wtx = it->second ;
1124
1128
int currentconfirm = wtx.GetDepthInMainChain ();
1125
1129
// If the orig tx was not in block, none of its spends can be
1126
1130
assert (currentconfirm <= 0 );
@@ -1145,8 +1149,10 @@ bool CWallet::AbandonTransaction(const uint256& hashTx)
1145
1149
// available of the outputs it spends. So force those to be recomputed
1146
1150
for (const CTxIn& txin : wtx.tx ->vin )
1147
1151
{
1148
- if (mapWallet.count (txin.prevout .hash ))
1149
- mapWallet[txin.prevout .hash ].MarkDirty ();
1152
+ auto it = mapWallet.find (txin.prevout .hash );
1153
+ if (it != mapWallet.end ()) {
1154
+ it->second .MarkDirty ();
1155
+ }
1150
1156
}
1151
1157
}
1152
1158
}
@@ -1184,8 +1190,9 @@ void CWallet::MarkConflicted(const uint256& hashBlock, const uint256& hashTx)
1184
1190
uint256 now = *todo.begin ();
1185
1191
todo.erase (now);
1186
1192
done.insert (now);
1187
- assert (mapWallet.count (now));
1188
- CWalletTx& wtx = mapWallet[now];
1193
+ auto it = mapWallet.find (now);
1194
+ assert (it != mapWallet.end ());
1195
+ CWalletTx& wtx = it->second ;
1189
1196
int currentconfirm = wtx.GetDepthInMainChain ();
1190
1197
if (conflictconfirms < currentconfirm) {
1191
1198
// Block is 'more conflicted' than current confirm; update.
@@ -1204,10 +1211,11 @@ void CWallet::MarkConflicted(const uint256& hashBlock, const uint256& hashTx)
1204
1211
}
1205
1212
// If a transaction changes 'conflicted' state, that changes the balance
1206
1213
// available of the outputs it spends. So force those to be recomputed
1207
- for (const CTxIn& txin : wtx.tx ->vin )
1208
- {
1209
- if (mapWallet.count (txin.prevout .hash ))
1210
- mapWallet[txin.prevout .hash ].MarkDirty ();
1214
+ for (const CTxIn& txin : wtx.tx ->vin ) {
1215
+ auto it = mapWallet.find (txin.prevout .hash );
1216
+ if (it != mapWallet.end ()) {
1217
+ it->second .MarkDirty ();
1218
+ }
1211
1219
}
1212
1220
}
1213
1221
}
@@ -1222,10 +1230,11 @@ void CWallet::SyncTransaction(const CTransactionRef& ptx, const CBlockIndex *pin
1222
1230
// If a transaction changes 'conflicted' state, that changes the balance
1223
1231
// available of the outputs it spends. So force those to be
1224
1232
// recomputed, also:
1225
- for (const CTxIn& txin : tx.vin )
1226
- {
1227
- if (mapWallet.count (txin.prevout .hash ))
1228
- mapWallet[txin.prevout .hash ].MarkDirty ();
1233
+ for (const CTxIn& txin : tx.vin ) {
1234
+ auto it = mapWallet.find (txin.prevout .hash );
1235
+ if (it != mapWallet.end ()) {
1236
+ it->second .MarkDirty ();
1237
+ }
1229
1238
}
1230
1239
}
1231
1240
0 commit comments