88#include < logging.h>
99#include < policy/policy.h>
1010#include < primitives/transaction.h>
11+ #include < util/time.h>
1112
1213#include < cassert>
1314
14- /* * Expiration time for orphan transactions in seconds */
15- static constexpr int64_t ORPHAN_TX_EXPIRE_TIME = 20 * 60 ;
16- /* * Minimum time between orphan transactions expire time checks in seconds */
17- static constexpr int64_t ORPHAN_TX_EXPIRE_INTERVAL = 5 * 60 ;
15+ /* * Expiration time for orphan transactions */
16+ static constexpr auto ORPHAN_TX_EXPIRE_TIME{20min} ;
17+ /* * Minimum time between orphan transactions expire time checks */
18+ static constexpr auto ORPHAN_TX_EXPIRE_INTERVAL{5min} ;
1819
1920
2021bool TxOrphanage::AddTx (const CTransactionRef& tx, NodeId peer)
@@ -40,7 +41,7 @@ bool TxOrphanage::AddTx(const CTransactionRef& tx, NodeId peer)
4041 return false ;
4142 }
4243
43- auto ret = m_orphans.emplace (wtxid, OrphanTx{tx, peer, GetTime () + ORPHAN_TX_EXPIRE_TIME, m_orphan_list.size ()});
44+ auto ret = m_orphans.emplace (wtxid, OrphanTx{tx, peer, Now<NodeSeconds> () + ORPHAN_TX_EXPIRE_TIME, m_orphan_list.size ()});
4445 assert (ret.second );
4546 m_orphan_list.push_back (ret.first );
4647 for (const CTxIn& txin : tx->vin ) {
@@ -90,7 +91,7 @@ int TxOrphanage::EraseTxNoLock(const Wtxid& wtxid)
9091 // Time spent in orphanage = difference between current and entry time.
9192 // Entry time is equal to ORPHAN_TX_EXPIRE_TIME earlier than entry's expiry.
9293 LogPrint (BCLog::TXPACKAGES, " removed orphan tx %s (wtxid=%s) after %ds\n " , txid.ToString (), wtxid.ToString (),
93- GetTime ( ) + ORPHAN_TX_EXPIRE_TIME - it->second .nTimeExpire );
94+ Ticks<std::chrono::seconds>( NodeClock::now ( ) + ORPHAN_TX_EXPIRE_TIME - it->second .nTimeExpire ) );
9495 m_orphan_list.pop_back ();
9596 m_wtxid_to_orphan_it.erase (wtxid);
9697
@@ -122,12 +123,12 @@ void TxOrphanage::LimitOrphans(unsigned int max_orphans, FastRandomContext& rng)
122123 LOCK (m_mutex);
123124
124125 unsigned int nEvicted = 0 ;
125- static int64_t nNextSweep;
126- int64_t nNow = GetTime () ;
126+ static NodeSeconds nNextSweep;
127+ auto nNow{Now<NodeSeconds>()} ;
127128 if (nNextSweep <= nNow) {
128129 // Sweep out expired orphan pool entries:
129130 int nErased = 0 ;
130- int64_t nMinExpTime = nNow + ORPHAN_TX_EXPIRE_TIME - ORPHAN_TX_EXPIRE_INTERVAL;
131+ auto nMinExpTime{ nNow + ORPHAN_TX_EXPIRE_TIME - ORPHAN_TX_EXPIRE_INTERVAL} ;
131132 std::map<Wtxid, OrphanTx>::iterator iter = m_orphans.begin ();
132133 while (iter != m_orphans.end ())
133134 {
0 commit comments