@@ -147,11 +147,11 @@ void CTxMemPool::UpdateTransactionsFromBlock(const std::vector<uint256> &vHashes
147
147
if (it == mapTx.end ()) {
148
148
continue ;
149
149
}
150
- std::map<COutPoint, CInPoint>::iterator iter = mapNextTx.lower_bound (COutPoint (hash, 0 ));
150
+ auto iter = mapNextTx.lower_bound (COutPoint (hash, 0 ));
151
151
// First calculate the children, and update setMemPoolChildren to
152
152
// include them, and update their setMemPoolParents to include this tx.
153
- for (; iter != mapNextTx.end () && iter->first . hash == hash; ++iter) {
154
- const uint256 &childHash = iter->second . ptx ->GetHash ();
153
+ for (; iter != mapNextTx.end () && iter->first -> hash == hash; ++iter) {
154
+ const uint256 &childHash = iter->second ->GetHash ();
155
155
txiter childIter = mapTx.find (childHash);
156
156
assert (childIter != mapTx.end ());
157
157
// We can skip updating entries we've encountered before or that
@@ -365,11 +365,11 @@ void CTxMemPool::pruneSpent(const uint256 &hashTx, CCoins &coins)
365
365
{
366
366
LOCK (cs);
367
367
368
- std::map<COutPoint, CInPoint>::iterator it = mapNextTx.lower_bound (COutPoint (hashTx, 0 ));
368
+ auto it = mapNextTx.lower_bound (COutPoint (hashTx, 0 ));
369
369
370
370
// iterate over all COutPoints in mapNextTx whose hash equals the provided hashTx
371
- while (it != mapNextTx.end () && it->first . hash == hashTx) {
372
- coins.Spend (it->first . n ); // and remove those outputs from coins
371
+ while (it != mapNextTx.end () && it->first -> hash == hashTx) {
372
+ coins.Spend (it->first -> n ); // and remove those outputs from coins
373
373
it++;
374
374
}
375
375
}
@@ -414,7 +414,7 @@ bool CTxMemPool::addUnchecked(const uint256& hash, const CTxMemPoolEntry &entry,
414
414
const CTransaction& tx = newit->GetTx ();
415
415
std::set<uint256> setParentTransactions;
416
416
for (unsigned int i = 0 ; i < tx.vin .size (); i++) {
417
- mapNextTx[ tx.vin [i].prevout ] = CInPoint ( &tx, i );
417
+ mapNextTx. insert ( std::make_pair (& tx.vin [i].prevout , &tx) );
418
418
setParentTransactions.insert (tx.vin [i].prevout .hash );
419
419
}
420
420
// Don't bother worrying about child transactions of this one.
@@ -500,10 +500,10 @@ void CTxMemPool::removeRecursive(const CTransaction &origTx, std::list<CTransact
500
500
// happen during chain re-orgs if origTx isn't re-accepted into
501
501
// the mempool for any reason.
502
502
for (unsigned int i = 0 ; i < origTx.vout .size (); i++) {
503
- std::map<COutPoint, CInPoint>::iterator it = mapNextTx.find (COutPoint (origTx.GetHash (), i));
503
+ auto it = mapNextTx.find (COutPoint (origTx.GetHash (), i));
504
504
if (it == mapNextTx.end ())
505
505
continue ;
506
- txiter nextit = mapTx.find (it->second . ptx ->GetHash ());
506
+ txiter nextit = mapTx.find (it->second ->GetHash ());
507
507
assert (nextit != mapTx.end ());
508
508
txToRemove.insert (nextit);
509
509
}
@@ -561,9 +561,9 @@ void CTxMemPool::removeConflicts(const CTransaction &tx, std::list<CTransaction>
561
561
list<CTransaction> result;
562
562
LOCK (cs);
563
563
BOOST_FOREACH (const CTxIn &txin, tx.vin ) {
564
- std::map<COutPoint, CInPoint>::iterator it = mapNextTx.find (txin.prevout );
564
+ auto it = mapNextTx.find (txin.prevout );
565
565
if (it != mapNextTx.end ()) {
566
- const CTransaction &txConflict = *it->second . ptx ;
566
+ const CTransaction &txConflict = *it->second ;
567
567
if (txConflict != tx)
568
568
{
569
569
removeRecursive (txConflict, removed);
@@ -671,10 +671,10 @@ void CTxMemPool::check(const CCoinsViewCache *pcoins) const
671
671
assert (coins && coins->IsAvailable (txin.prevout .n ));
672
672
}
673
673
// Check whether its inputs are marked in mapNextTx.
674
- std::map<COutPoint, CInPoint>::const_iterator it3 = mapNextTx.find (txin.prevout );
674
+ auto it3 = mapNextTx.find (txin.prevout );
675
675
assert (it3 != mapNextTx.end ());
676
- assert (it3->second . ptx == &tx );
677
- assert (it3->second . n == i );
676
+ assert (it3->first == &txin. prevout );
677
+ assert (it3->second == &tx );
678
678
i++;
679
679
}
680
680
assert (setParentCheck == GetMemPoolParents (it));
@@ -701,10 +701,10 @@ void CTxMemPool::check(const CCoinsViewCache *pcoins) const
701
701
702
702
// Check children against mapNextTx
703
703
CTxMemPool::setEntries setChildrenCheck;
704
- std::map<COutPoint, CInPoint>::const_iterator iter = mapNextTx.lower_bound (COutPoint (it->GetTx ().GetHash (), 0 ));
704
+ auto iter = mapNextTx.lower_bound (COutPoint (it->GetTx ().GetHash (), 0 ));
705
705
int64_t childSizes = 0 ;
706
- for (; iter != mapNextTx.end () && iter->first . hash == it->GetTx ().GetHash (); ++iter) {
707
- txiter childit = mapTx.find (iter->second . ptx ->GetHash ());
706
+ for (; iter != mapNextTx.end () && iter->first -> hash == it->GetTx ().GetHash (); ++iter) {
707
+ txiter childit = mapTx.find (iter->second ->GetHash ());
708
708
assert (childit != mapTx.end ()); // mapNextTx points to in-mempool transactions
709
709
if (setChildrenCheck.insert (childit).second ) {
710
710
childSizes += childit->GetTxSize ();
@@ -738,14 +738,12 @@ void CTxMemPool::check(const CCoinsViewCache *pcoins) const
738
738
stepsSinceLastRemove = 0 ;
739
739
}
740
740
}
741
- for (std::map<COutPoint, CInPoint>::const_iterator it = mapNextTx.begin (); it != mapNextTx.end (); it++) {
742
- uint256 hash = it->second . ptx ->GetHash ();
741
+ for (auto it = mapNextTx.cbegin (); it != mapNextTx.cend (); it++) {
742
+ uint256 hash = it->second ->GetHash ();
743
743
indexed_transaction_set::const_iterator it2 = mapTx.find (hash);
744
744
const CTransaction& tx = it2->GetTx ();
745
745
assert (it2 != mapTx.end ());
746
- assert (&tx == it->second .ptx );
747
- assert (tx.vin .size () > it->second .n );
748
- assert (it->first == it->second .ptx ->vin [it->second .n ].prevout );
746
+ assert (&tx == it->second );
749
747
}
750
748
751
749
assert (totalTxSize == checkTotal);
@@ -1079,8 +1077,8 @@ void CTxMemPool::TrimToSize(size_t sizelimit, std::vector<uint256>* pvNoSpendsRe
1079
1077
BOOST_FOREACH (const CTxIn& txin, tx.vin ) {
1080
1078
if (exists (txin.prevout .hash ))
1081
1079
continue ;
1082
- std::map<COutPoint, CInPoint>::iterator it = mapNextTx.lower_bound (COutPoint (txin.prevout .hash , 0 ));
1083
- if (it == mapNextTx.end () || it->first . hash != txin.prevout .hash )
1080
+ auto it = mapNextTx.lower_bound (COutPoint (txin.prevout .hash , 0 ));
1081
+ if (it == mapNextTx.end () || it->first -> hash != txin.prevout .hash )
1084
1082
pvNoSpendsRemaining->push_back (txin.prevout .hash );
1085
1083
}
1086
1084
}
0 commit comments