aboutsummaryrefslogtreecommitdiff
path: root/src/txorphanage.h
diff options
context:
space:
mode:
authorAnthony Towns <aj@erisian.com.au>2021-02-25 00:28:16 +1000
committerAnthony Towns <aj@erisian.com.au>2022-10-11 14:05:09 +1000
commita936f41a5d5f7bb97425f82ec64dfae62e840a56 (patch)
treea7d8e962139d566375a83ee191af3c204a7e8f0f /src/txorphanage.h
parent3614819864a84ac32f6d53c6ace79b5e71bc174a (diff)
txorphanage: make m_peer_work_set private
Diffstat (limited to 'src/txorphanage.h')
-rw-r--r--src/txorphanage.h19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/txorphanage.h b/src/txorphanage.h
index aff57e84f7..5af1f2f0e0 100644
--- a/src/txorphanage.h
+++ b/src/txorphanage.h
@@ -10,6 +10,9 @@
#include <primitives/transaction.h>
#include <sync.h>
+#include <map>
+#include <set>
+
/** Guards orphan transactions */
extern RecursiveMutex g_cs_orphans;
@@ -26,10 +29,14 @@ public:
/** Check if we already have an orphan transaction (by txid or wtxid) */
bool HaveTx(const GenTxid& gtxid) const LOCKS_EXCLUDED(::g_cs_orphans);
- /** Get an orphan transaction and its originating peer
- * (Transaction ref will be nullptr if not found)
+ /** Extract a transaction from a peer's work set
+ * Returns nullptr and sets more to false if there are no transactions
+ * to work on. Otherwise returns the transaction reference, removes
+ * the transaction from the work set, and populates its arguments with
+ * the originating peer, and whether there are more orphans for this peer
+ * to work on after this tx.
*/
- std::pair<CTransactionRef, NodeId> GetTx(const uint256& txid) const EXCLUSIVE_LOCKS_REQUIRED(g_cs_orphans);
+ CTransactionRef GetTxToReconsider(NodeId peer, NodeId& originator, bool& more) EXCLUSIVE_LOCKS_REQUIRED(g_cs_orphans);
/** Erase an orphan by txid */
int EraseTx(const uint256& txid) EXCLUSIVE_LOCKS_REQUIRED(g_cs_orphans);
@@ -43,9 +50,6 @@ public:
/** Limit the orphanage to the given maximum */
void LimitOrphans(unsigned int max_orphans) EXCLUSIVE_LOCKS_REQUIRED(g_cs_orphans);
- /** Which peer provided a parent tx of orphans that need to be reconsidered */
- std::map<NodeId, std::set<uint256>> m_peer_work_set GUARDED_BY(g_cs_orphans);
-
/** Add any orphans that list a particular tx as a parent into a peer's work set */
void AddChildrenToWorkSet(const CTransaction& tx, NodeId peer) EXCLUSIVE_LOCKS_REQUIRED(g_cs_orphans);
@@ -68,6 +72,9 @@ protected:
* -maxorphantx/DEFAULT_MAX_ORPHAN_TRANSACTIONS */
std::map<uint256, OrphanTx> m_orphans GUARDED_BY(g_cs_orphans);
+ /** Which peer provided a parent tx of orphans that need to be reconsidered */
+ std::map<NodeId, std::set<uint256>> m_peer_work_set GUARDED_BY(g_cs_orphans);
+
using OrphanMap = decltype(m_orphans);
struct IteratorComparator