@@ -532,11 +532,11 @@ void CWallet::SyncMetaData(std::pair<TxSpends::iterator, TxSpends::iterator> ran
532532 for (TxSpends::iterator it = range.first ; it != range.second ; ++it)
533533 {
534534 const uint256& hash = it->second ;
535- int n = mapWallet[ hash] .nOrderPos ;
535+ int n = mapWallet. at ( hash) .nOrderPos ;
536536 if (n < nMinOrderPos)
537537 {
538538 nMinOrderPos = n;
539- copyFrom = &mapWallet[ hash] ;
539+ copyFrom = &mapWallet. at ( hash) ;
540540 }
541541 }
542542
@@ -546,7 +546,7 @@ void CWallet::SyncMetaData(std::pair<TxSpends::iterator, TxSpends::iterator> ran
546546 for (TxSpends::iterator it = range.first ; it != range.second ; ++it)
547547 {
548548 const uint256& hash = it->second ;
549- CWalletTx* copyTo = &mapWallet[ hash] ;
549+ CWalletTx* copyTo = &mapWallet. at ( hash) ;
550550 if (copyFrom == copyTo) continue ;
551551 assert (copyFrom && " Oldest wallet transaction in range assumed to have been found." );
552552 if (!copyFrom->IsEquivalentTo (*copyTo)) continue ;
@@ -985,8 +985,11 @@ bool CWallet::LoadToWallet(const CWalletTx& wtxIn)
985985{
986986 uint256 hash = wtxIn.GetHash ();
987987
988- mapWallet[hash] = wtxIn;
989- CWalletTx& wtx = mapWallet[hash];
988+ auto inserted = mapWallet.emplace (hash, wtxIn);
989+ CWalletTx& wtx = inserted.first ->second ;
990+ if (!inserted.second ) {
991+ wtx = wtxIn;
992+ }
990993 wtx.BindWallet (this );
991994 wtxOrdered.insert (std::make_pair (wtx.nOrderPos , TxPair (&wtx, nullptr )));
992995 AddToSpends (hash);
@@ -3027,7 +3030,7 @@ bool CWallet::CommitTransaction(CTransactionRef tx, mapValue_t mapValue, std::ve
30273030 // Notify that old coins are spent
30283031 for (const CTxIn& txin : wtxNew.tx ->vin )
30293032 {
3030- CWalletTx &coin = mapWallet[ txin.prevout .hash ] ;
3033+ CWalletTx &coin = mapWallet. at ( txin.prevout .hash ) ;
30313034 coin.BindWallet (this );
30323035 NotifyTransactionChanged (this , coin.GetHash (), CT_UPDATED);
30333036 }
@@ -3038,7 +3041,7 @@ bool CWallet::CommitTransaction(CTransactionRef tx, mapValue_t mapValue, std::ve
30383041
30393042 // Get the inserted-CWalletTx from mapWallet so that the
30403043 // fInMempool flag is cached properly
3041- CWalletTx& wtx = mapWallet[ wtxNew.GetHash ()] ;
3044+ CWalletTx& wtx = mapWallet. at ( wtxNew.GetHash ()) ;
30423045
30433046 if (fBroadcastTransactions )
30443047 {
@@ -3494,7 +3497,7 @@ std::set< std::set<CTxDestination> > CWallet::GetAddressGroupings()
34943497 CTxDestination address;
34953498 if (!IsMine (txin)) /* If this input isn't mine, ignore it */
34963499 continue ;
3497- if (!ExtractDestination (mapWallet[ txin.prevout .hash ] .tx ->vout [txin.prevout .n ].scriptPubKey , address))
3500+ if (!ExtractDestination (mapWallet. at ( txin.prevout .hash ) .tx ->vout [txin.prevout .n ].scriptPubKey , address))
34983501 continue ;
34993502 grouping.insert (address);
35003503 any_mine = true ;
0 commit comments