@@ -526,11 +526,11 @@ void CWallet::SyncMetaData(std::pair<TxSpends::iterator, TxSpends::iterator> ran
526526 for (TxSpends::iterator it = range.first ; it != range.second ; ++it)
527527 {
528528 const uint256& hash = it->second ;
529- int n = mapWallet[ hash] .nOrderPos ;
529+ int n = mapWallet. at ( hash) .nOrderPos ;
530530 if (n < nMinOrderPos)
531531 {
532532 nMinOrderPos = n;
533- copyFrom = &mapWallet[ hash] ;
533+ copyFrom = &mapWallet. at ( hash) ;
534534 }
535535 }
536536
@@ -540,7 +540,7 @@ void CWallet::SyncMetaData(std::pair<TxSpends::iterator, TxSpends::iterator> ran
540540 for (TxSpends::iterator it = range.first ; it != range.second ; ++it)
541541 {
542542 const uint256& hash = it->second ;
543- CWalletTx* copyTo = &mapWallet[ hash] ;
543+ CWalletTx* copyTo = &mapWallet. at ( hash) ;
544544 if (copyFrom == copyTo) continue ;
545545 assert (copyFrom && " Oldest wallet transaction in range assumed to have been found." );
546546 if (!copyFrom->IsEquivalentTo (*copyTo)) continue ;
@@ -979,8 +979,11 @@ bool CWallet::LoadToWallet(const CWalletTx& wtxIn)
979979{
980980 uint256 hash = wtxIn.GetHash ();
981981
982- mapWallet[hash] = wtxIn;
983- CWalletTx& wtx = mapWallet[hash];
982+ auto inserted = mapWallet.emplace (hash, wtxIn);
983+ CWalletTx& wtx = inserted.first ->second ;
984+ if (!inserted.second ) {
985+ wtx = wtxIn;
986+ }
984987 wtx.BindWallet (this );
985988 wtxOrdered.insert (std::make_pair (wtx.nOrderPos , TxPair (&wtx, nullptr )));
986989 AddToSpends (hash);
@@ -3023,7 +3026,7 @@ bool CWallet::CommitTransaction(CTransactionRef tx, mapValue_t mapValue, std::ve
30233026 // Notify that old coins are spent
30243027 for (const CTxIn& txin : wtxNew.tx ->vin )
30253028 {
3026- CWalletTx &coin = mapWallet[ txin.prevout .hash ] ;
3029+ CWalletTx &coin = mapWallet. at ( txin.prevout .hash ) ;
30273030 coin.BindWallet (this );
30283031 NotifyTransactionChanged (this , coin.GetHash (), CT_UPDATED);
30293032 }
@@ -3034,7 +3037,7 @@ bool CWallet::CommitTransaction(CTransactionRef tx, mapValue_t mapValue, std::ve
30343037
30353038 // Get the inserted-CWalletTx from mapWallet so that the
30363039 // fInMempool flag is cached properly
3037- CWalletTx& wtx = mapWallet[ wtxNew.GetHash ()] ;
3040+ CWalletTx& wtx = mapWallet. at ( wtxNew.GetHash ()) ;
30383041
30393042 if (fBroadcastTransactions )
30403043 {
@@ -3490,7 +3493,7 @@ std::set< std::set<CTxDestination> > CWallet::GetAddressGroupings()
34903493 CTxDestination address;
34913494 if (!IsMine (txin)) /* If this input isn't mine, ignore it */
34923495 continue ;
3493- if (!ExtractDestination (mapWallet[ txin.prevout .hash ] .tx ->vout [txin.prevout .n ].scriptPubKey , address))
3496+ if (!ExtractDestination (mapWallet. at ( txin.prevout .hash ) .tx ->vout [txin.prevout .n ].scriptPubKey , address))
34943497 continue ;
34953498 grouping.insert (address);
34963499 any_mine = true ;
0 commit comments