@@ -51,7 +51,7 @@ struct IteratorComparator
51
51
52
52
struct COrphanTx {
53
53
// When modifying, adapt the copy of this definition in tests/DoS_tests.
54
- CTransaction tx;
54
+ CTransactionRef tx;
55
55
NodeId fromPeer;
56
56
int64_t nTimeExpire;
57
57
};
@@ -586,9 +586,9 @@ void UnregisterNodeSignals(CNodeSignals& nodeSignals)
586
586
// mapOrphanTransactions
587
587
//
588
588
589
- bool AddOrphanTx (const CTransaction & tx, NodeId peer) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
589
+ bool AddOrphanTx (const CTransactionRef & tx, NodeId peer) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
590
590
{
591
- uint256 hash = tx. GetHash ();
591
+ const uint256& hash = tx-> GetHash ();
592
592
if (mapOrphanTransactions.count (hash))
593
593
return false ;
594
594
@@ -599,7 +599,7 @@ bool AddOrphanTx(const CTransaction& tx, NodeId peer) EXCLUSIVE_LOCKS_REQUIRED(c
599
599
// have been mined or received.
600
600
// 100 orphans, each of which is at most 99,999 bytes big is
601
601
// at most 10 megabytes of orphans and somewhat more byprev index (in the worst case):
602
- unsigned int sz = GetTransactionWeight (tx);
602
+ unsigned int sz = GetTransactionWeight (* tx);
603
603
if (sz >= MAX_STANDARD_TX_WEIGHT)
604
604
{
605
605
LogPrint (" mempool" , " ignoring large orphan tx (size: %u, hash: %s)\n " , sz, hash.ToString ());
@@ -608,7 +608,7 @@ bool AddOrphanTx(const CTransaction& tx, NodeId peer) EXCLUSIVE_LOCKS_REQUIRED(c
608
608
609
609
auto ret = mapOrphanTransactions.emplace (hash, COrphanTx{tx, peer, GetTime () + ORPHAN_TX_EXPIRE_TIME});
610
610
assert (ret.second );
611
- BOOST_FOREACH (const CTxIn& txin, tx. vin ) {
611
+ BOOST_FOREACH (const CTxIn& txin, tx-> vin ) {
612
612
mapOrphanTransactionsByPrev[txin.prevout ].insert (ret.first );
613
613
}
614
614
@@ -622,7 +622,7 @@ int static EraseOrphanTx(uint256 hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
622
622
map<uint256, COrphanTx>::iterator it = mapOrphanTransactions.find (hash);
623
623
if (it == mapOrphanTransactions.end ())
624
624
return 0 ;
625
- BOOST_FOREACH (const CTxIn& txin, it->second .tx . vin )
625
+ BOOST_FOREACH (const CTxIn& txin, it->second .tx -> vin )
626
626
{
627
627
auto itPrev = mapOrphanTransactionsByPrev.find (txin.prevout );
628
628
if (itPrev == mapOrphanTransactionsByPrev.end ())
@@ -644,7 +644,7 @@ void EraseOrphansFor(NodeId peer)
644
644
map<uint256, COrphanTx>::iterator maybeErase = iter++; // increment to avoid iterator becoming invalid
645
645
if (maybeErase->second .fromPeer == peer)
646
646
{
647
- nErased += EraseOrphanTx (maybeErase->second .tx . GetHash ());
647
+ nErased += EraseOrphanTx (maybeErase->second .tx -> GetHash ());
648
648
}
649
649
}
650
650
if (nErased > 0 ) LogPrint (" mempool" , " Erased %d orphan tx from peer %d\n " , nErased, peer);
@@ -665,7 +665,7 @@ unsigned int LimitOrphanTxSize(unsigned int nMaxOrphans) EXCLUSIVE_LOCKS_REQUIRE
665
665
{
666
666
map<uint256, COrphanTx>::iterator maybeErase = iter++;
667
667
if (maybeErase->second .nTimeExpire <= nNow) {
668
- nErased += EraseOrphanTx (maybeErase->second .tx . GetHash ());
668
+ nErased += EraseOrphanTx (maybeErase->second .tx -> GetHash ());
669
669
} else {
670
670
nMinExpTime = std::min (maybeErase->second .nTimeExpire , nMinExpTime);
671
671
}
@@ -736,7 +736,7 @@ void PeerLogicValidation::SyncTransaction(const CTransaction& tx, const CBlockIn
736
736
auto itByPrev = mapOrphanTransactionsByPrev.find (tx.vin [j].prevout );
737
737
if (itByPrev == mapOrphanTransactionsByPrev.end ()) continue ;
738
738
for (auto mi = itByPrev->second .begin (); mi != itByPrev->second .end (); ++mi) {
739
- const CTransaction& orphanTx = (*mi)->second .tx ;
739
+ const CTransaction& orphanTx = * (*mi)->second .tx ;
740
740
const uint256& orphanHash = orphanTx.GetHash ();
741
741
vOrphanErase.push_back (orphanHash);
742
742
}
@@ -1636,7 +1636,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
1636
1636
mi != itByPrev->second .end ();
1637
1637
++mi)
1638
1638
{
1639
- const CTransaction& orphanTx = (*mi)->second .tx ;
1639
+ const CTransactionRef& porphanTx = (*mi)->second .tx ;
1640
+ const CTransaction& orphanTx = *porphanTx;
1640
1641
const uint256& orphanHash = orphanTx.GetHash ();
1641
1642
NodeId fromPeer = (*mi)->second .fromPeer ;
1642
1643
bool fMissingInputs2 = false ;
@@ -1648,7 +1649,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
1648
1649
1649
1650
if (setMisbehaving.count (fromPeer))
1650
1651
continue ;
1651
- if (AcceptToMemoryPool (mempool, stateDummy, MakeTransactionRef (orphanTx) , true , &fMissingInputs2 )) {
1652
+ if (AcceptToMemoryPool (mempool, stateDummy, porphanTx , true , &fMissingInputs2 )) {
1652
1653
LogPrint (" mempool" , " accepted orphan tx %s\n " , orphanHash.ToString ());
1653
1654
RelayTransaction (orphanTx, connman);
1654
1655
for (unsigned int i = 0 ; i < orphanTx.vout .size (); i++) {
@@ -1701,7 +1702,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
1701
1702
pfrom->AddInventoryKnown (_inv);
1702
1703
if (!AlreadyHave (_inv)) pfrom->AskFor (_inv);
1703
1704
}
1704
- AddOrphanTx (tx , pfrom->GetId ());
1705
+ AddOrphanTx (ptx , pfrom->GetId ());
1705
1706
1706
1707
// DoS prevention: do not allow mapOrphanTransactions to grow unbounded
1707
1708
unsigned int nMaxOrphanTx = (unsigned int )std::max ((int64_t )0 , GetArg (" -maxorphantx" , DEFAULT_MAX_ORPHAN_TRANSACTIONS));
0 commit comments