@@ -562,18 +562,18 @@ void CWallet::SyncMetaData(std::pair<TxSpends::iterator, TxSpends::iterator> ran
562562 for (TxSpends::iterator it = range.first ; it != range.second ; ++it)
563563 {
564564 const uint256& hash = it->second ;
565- int n = mapWallet[ hash] .nOrderPos ;
565+ int n = mapWallet. at ( hash) .nOrderPos ;
566566 if (n < nMinOrderPos)
567567 {
568568 nMinOrderPos = n;
569- copyFrom = &mapWallet[ hash] ;
569+ copyFrom = &mapWallet. at ( hash) ;
570570 }
571571 }
572572 // Now copy data from copyFrom to rest:
573573 for (TxSpends::iterator it = range.first ; it != range.second ; ++it)
574574 {
575575 const uint256& hash = it->second ;
576- CWalletTx* copyTo = &mapWallet[ hash] ;
576+ CWalletTx* copyTo = &mapWallet. at ( hash) ;
577577 if (copyFrom == copyTo) continue ;
578578 if (!copyFrom->IsEquivalentTo (*copyTo)) continue ;
579579 copyTo->mapValue = copyFrom->mapValue ;
@@ -624,7 +624,7 @@ void CWallet::AddToSpends(const COutPoint& outpoint, const uint256& wtxid)
624624void CWallet::AddToSpends (const uint256& wtxid)
625625{
626626 assert (mapWallet.count (wtxid));
627- CWalletTx& thisTx = mapWallet[ wtxid] ;
627+ CWalletTx& thisTx = mapWallet. at ( wtxid) ;
628628 if (thisTx.IsCoinBase ()) // Coinbases don't spend anything!
629629 return ;
630630
@@ -1001,14 +1001,17 @@ bool CWallet::LoadToWallet(const CWalletTx& wtxIn)
10011001{
10021002 uint256 hash = wtxIn.GetHash ();
10031003
1004- mapWallet[hash] = wtxIn;
1005- CWalletTx& wtx = mapWallet[hash];
1004+ auto inserted = mapWallet.emplace (hash, wtxIn);
1005+ CWalletTx& wtx = inserted.first ->second ;
1006+ if (!inserted.second ) {
1007+ wtx = wtxIn;
1008+ }
10061009 wtx.BindWallet (this );
10071010 wtxOrdered.insert (std::make_pair (wtx.nOrderPos , TxPair (&wtx, (CAccountingEntry*)0 )));
10081011 AddToSpends (hash);
10091012 for (const CTxIn& txin : wtx.tx ->vin ) {
10101013 if (mapWallet.count (txin.prevout .hash )) {
1011- CWalletTx& prevtx = mapWallet[ txin.prevout .hash ] ;
1014+ CWalletTx& prevtx = mapWallet. at ( txin.prevout .hash ) ;
10121015 if (prevtx.nIndex == -1 && !prevtx.hashUnset ()) {
10131016 MarkConflicted (prevtx.hashBlock , wtx.GetHash ());
10141017 }
@@ -1108,7 +1111,7 @@ bool CWallet::AbandonTransaction(const uint256& hashTx)
11081111
11091112 // Can't mark abandoned if confirmed or in mempool
11101113 assert (mapWallet.count (hashTx));
1111- CWalletTx& origtx = mapWallet[ hashTx] ;
1114+ CWalletTx& origtx = mapWallet. at ( hashTx) ;
11121115 if (origtx.GetDepthInMainChain () > 0 || origtx.InMempool ()) {
11131116 return false ;
11141117 }
@@ -1120,7 +1123,7 @@ bool CWallet::AbandonTransaction(const uint256& hashTx)
11201123 todo.erase (now);
11211124 done.insert (now);
11221125 assert (mapWallet.count (now));
1123- CWalletTx& wtx = mapWallet[ now] ;
1126+ CWalletTx& wtx = mapWallet. at ( now) ;
11241127 int currentconfirm = wtx.GetDepthInMainChain ();
11251128 // If the orig tx was not in block, none of its spends can be
11261129 assert (currentconfirm <= 0 );
@@ -1146,7 +1149,7 @@ bool CWallet::AbandonTransaction(const uint256& hashTx)
11461149 for (const CTxIn& txin : wtx.tx ->vin )
11471150 {
11481151 if (mapWallet.count (txin.prevout .hash ))
1149- mapWallet[ txin.prevout .hash ] .MarkDirty ();
1152+ mapWallet. at ( txin.prevout .hash ) .MarkDirty ();
11501153 }
11511154 }
11521155 }
@@ -1185,7 +1188,7 @@ void CWallet::MarkConflicted(const uint256& hashBlock, const uint256& hashTx)
11851188 todo.erase (now);
11861189 done.insert (now);
11871190 assert (mapWallet.count (now));
1188- CWalletTx& wtx = mapWallet[ now] ;
1191+ CWalletTx& wtx = mapWallet. at ( now) ;
11891192 int currentconfirm = wtx.GetDepthInMainChain ();
11901193 if (conflictconfirms < currentconfirm) {
11911194 // Block is 'more conflicted' than current confirm; update.
@@ -1207,7 +1210,7 @@ void CWallet::MarkConflicted(const uint256& hashBlock, const uint256& hashTx)
12071210 for (const CTxIn& txin : wtx.tx ->vin )
12081211 {
12091212 if (mapWallet.count (txin.prevout .hash ))
1210- mapWallet[ txin.prevout .hash ] .MarkDirty ();
1213+ mapWallet. at ( txin.prevout .hash ) .MarkDirty ();
12111214 }
12121215 }
12131216 }
@@ -1225,7 +1228,7 @@ void CWallet::SyncTransaction(const CTransactionRef& ptx, const CBlockIndex *pin
12251228 for (const CTxIn& txin : tx.vin )
12261229 {
12271230 if (mapWallet.count (txin.prevout .hash ))
1228- mapWallet[ txin.prevout .hash ] .MarkDirty ();
1231+ mapWallet. at ( txin.prevout .hash ) .MarkDirty ();
12291232 }
12301233}
12311234
@@ -2988,7 +2991,7 @@ bool CWallet::CommitTransaction(CTransactionRef tx, mapValue_t mapValue, std::ve
29882991 // Notify that old coins are spent
29892992 for (const CTxIn& txin : wtxNew.tx ->vin )
29902993 {
2991- CWalletTx &coin = mapWallet[ txin.prevout .hash ] ;
2994+ CWalletTx &coin = mapWallet. at ( txin.prevout .hash ) ;
29922995 coin.BindWallet (this );
29932996 NotifyTransactionChanged (this , coin.GetHash (), CT_UPDATED);
29942997 }
@@ -3523,7 +3526,7 @@ std::set< std::set<CTxDestination> > CWallet::GetAddressGroupings()
35233526 CTxDestination address;
35243527 if (!IsMine (txin)) /* If this input isn't mine, ignore it */
35253528 continue ;
3526- if (!ExtractDestination (mapWallet[ txin.prevout .hash ] .tx ->vout [txin.prevout .n ].scriptPubKey , address))
3529+ if (!ExtractDestination (mapWallet. at ( txin.prevout .hash ) .tx ->vout [txin.prevout .n ].scriptPubKey , address))
35273530 continue ;
35283531 grouping.insert (address);
35293532 any_mine = true ;
0 commit comments