@@ -590,8 +590,9 @@ void CWallet::AddToSpends(const COutPoint& outpoint, const uint256& wtxid)
590
590
591
591
void CWallet::AddToSpends (const uint256& wtxid)
592
592
{
593
- assert (mapWallet.count (wtxid));
594
- CWalletTx& thisTx = mapWallet[wtxid];
593
+ auto it = mapWallet.find (wtxid);
594
+ assert (it != mapWallet.end ());
595
+ CWalletTx& thisTx = it->second ;
595
596
if (thisTx.IsCoinBase ()) // Coinbases don't spend anything!
596
597
return ;
597
598
@@ -974,8 +975,9 @@ bool CWallet::LoadToWallet(const CWalletTx& wtxIn)
974
975
wtxOrdered.insert (std::make_pair (wtx.nOrderPos , TxPair (&wtx, (CAccountingEntry*)0 )));
975
976
AddToSpends (hash);
976
977
for (const CTxIn& txin : wtx.tx ->vin ) {
977
- if (mapWallet.count (txin.prevout .hash )) {
978
- CWalletTx& prevtx = mapWallet[txin.prevout .hash ];
978
+ auto it = mapWallet.find (txin.prevout .hash );
979
+ if (it != mapWallet.end ()) {
980
+ CWalletTx& prevtx = it->second ;
979
981
if (prevtx.nIndex == -1 && !prevtx.hashUnset ()) {
980
982
MarkConflicted (prevtx.hashBlock , wtx.GetHash ());
981
983
}
@@ -1050,8 +1052,9 @@ bool CWallet::AbandonTransaction(const uint256& hashTx)
1050
1052
std::set<uint256> done;
1051
1053
1052
1054
// Can't mark abandoned if confirmed or in mempool
1053
- assert (mapWallet.count (hashTx));
1054
- CWalletTx& origtx = mapWallet[hashTx];
1055
+ auto it = mapWallet.find (hashTx);
1056
+ assert (it != mapWallet.end ());
1057
+ CWalletTx& origtx = it->second ;
1055
1058
if (origtx.GetDepthInMainChain () > 0 || origtx.InMempool ()) {
1056
1059
return false ;
1057
1060
}
@@ -1062,8 +1065,9 @@ bool CWallet::AbandonTransaction(const uint256& hashTx)
1062
1065
uint256 now = *todo.begin ();
1063
1066
todo.erase (now);
1064
1067
done.insert (now);
1065
- assert (mapWallet.count (now));
1066
- CWalletTx& wtx = mapWallet[now];
1068
+ auto it = mapWallet.find (now);
1069
+ assert (it != mapWallet.end ());
1070
+ CWalletTx& wtx = it->second ;
1067
1071
int currentconfirm = wtx.GetDepthInMainChain ();
1068
1072
// If the orig tx was not in block, none of its spends can be
1069
1073
assert (currentconfirm <= 0 );
@@ -1088,8 +1092,10 @@ bool CWallet::AbandonTransaction(const uint256& hashTx)
1088
1092
// available of the outputs it spends. So force those to be recomputed
1089
1093
for (const CTxIn& txin : wtx.tx ->vin )
1090
1094
{
1091
- if (mapWallet.count (txin.prevout .hash ))
1092
- mapWallet[txin.prevout .hash ].MarkDirty ();
1095
+ auto it = mapWallet.find (txin.prevout .hash );
1096
+ if (it != mapWallet.end ()) {
1097
+ it->second .MarkDirty ();
1098
+ }
1093
1099
}
1094
1100
}
1095
1101
}
@@ -1127,8 +1133,9 @@ void CWallet::MarkConflicted(const uint256& hashBlock, const uint256& hashTx)
1127
1133
uint256 now = *todo.begin ();
1128
1134
todo.erase (now);
1129
1135
done.insert (now);
1130
- assert (mapWallet.count (now));
1131
- CWalletTx& wtx = mapWallet[now];
1136
+ auto it = mapWallet.find (now);
1137
+ assert (it != mapWallet.end ());
1138
+ CWalletTx& wtx = it->second ;
1132
1139
int currentconfirm = wtx.GetDepthInMainChain ();
1133
1140
if (conflictconfirms < currentconfirm) {
1134
1141
// Block is 'more conflicted' than current confirm; update.
@@ -1147,10 +1154,11 @@ void CWallet::MarkConflicted(const uint256& hashBlock, const uint256& hashTx)
1147
1154
}
1148
1155
// If a transaction changes 'conflicted' state, that changes the balance
1149
1156
// available of the outputs it spends. So force those to be recomputed
1150
- for (const CTxIn& txin : wtx.tx ->vin )
1151
- {
1152
- if (mapWallet.count (txin.prevout .hash ))
1153
- mapWallet[txin.prevout .hash ].MarkDirty ();
1157
+ for (const CTxIn& txin : wtx.tx ->vin ) {
1158
+ auto it = mapWallet.find (txin.prevout .hash );
1159
+ if (it != mapWallet.end ()) {
1160
+ it->second .MarkDirty ();
1161
+ }
1154
1162
}
1155
1163
}
1156
1164
}
@@ -1165,10 +1173,11 @@ void CWallet::SyncTransaction(const CTransactionRef& ptx, const CBlockIndex *pin
1165
1173
// If a transaction changes 'conflicted' state, that changes the balance
1166
1174
// available of the outputs it spends. So force those to be
1167
1175
// recomputed, also:
1168
- for (const CTxIn& txin : tx.vin )
1169
- {
1170
- if (mapWallet.count (txin.prevout .hash ))
1171
- mapWallet[txin.prevout .hash ].MarkDirty ();
1176
+ for (const CTxIn& txin : tx.vin ) {
1177
+ auto it = mapWallet.find (txin.prevout .hash );
1178
+ if (it != mapWallet.end ()) {
1179
+ it->second .MarkDirty ();
1180
+ }
1172
1181
}
1173
1182
}
1174
1183
0 commit comments