multi_index: fix compilation failure with boost >= 1.91
What changed, and why it matters
This commit fixes a build failure that occurs when compiling Bitcoin Core with Boost version 1.91 or newer. It changes how certain in-memory data structures (used for tracking orphan transactions, mempool entries, and transaction requests) are declared so they compile with both old and new Boost versions. There is no runtime behavior change, no vulnerability fix, and no security impact.
No security action needed. Treat as a normal build-compatibility fix.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit reverts a prior refactoring (PR #30194) that extracted boost::multi_index::indexed_by into a separate inherited struct to reduce type signature verbosity. Boost 1.91 removed support for the pre-C++11 workaround machinery that made that pattern work, causing compilation failures. The fix inlines the indexed_by definition directly inside the boost::multi_index_container type alias in src/node/txorphanage.cpp, src/txmempool.h, and src/txrequest.cpp. This is a source-level compatibility change only.
Changed components
src/node/txorphanage.cppsrc/txmempool.hsrc/txrequest.cppInspect captured patch +16 / −19
diff --git a/src/node/txorphanage.cpp b/src/node/txorphanage.cpp
index ca7eb204..4b25ab4d 100644
--- a/src/node/txorphanage.cpp
+++ b/src/node/txorphanage.cpp
@@ -91,12 +91,13 @@ class TxOrphanageImpl final : public TxOrphanage {
}
};
- struct OrphanIndices final : boost::multi_index::indexed_by<
- boost::multi_index::ordered_unique<boost::multi_index::tag<ByWtxid>, WtxidExtractor>,
- boost::multi_index::ordered_unique<boost::multi_index::tag<ByPeer>, ByPeerViewExtractor>
- >{};
-
- using AnnouncementMap = boost::multi_index::multi_index_container<Announcement, OrphanIndices>;
+ using AnnouncementMap = boost::multi_index::multi_index_container<
+ Announcement,
+ boost::multi_index::indexed_by<
+ boost::multi_index::ordered_unique<boost::multi_index::tag<ByWtxid>, WtxidExtractor>,
+ boost::multi_index::ordered_unique<boost::multi_index::tag<ByPeer>, ByPeerViewExtractor>
+ >
+ >;
template<typename Tag>
using Iter = typename AnnouncementMap::index<Tag>::type::iterator;
AnnouncementMap m_orphans;
diff --git a/src/txmempool.h b/src/txmempool.h
index c4723f89..ae59057c 100644
--- a/src/txmempool.h
+++ b/src/txmempool.h
@@ -211,7 +211,9 @@ public:
static const int ROLLING_FEE_HALFLIFE = 60 * 60 * 12; // public only for testing
- struct CTxMemPoolEntry_Indices final : boost::multi_index::indexed_by<
+ using indexed_transaction_set = boost::multi_index_container<
+ CTxMemPoolEntry,
+ boost::multi_index::indexed_by<
// sorted by txid
boost::multi_index::hashed_unique<mempoolentry_txid, SaltedTxidHasher>,
// sorted by wtxid
@@ -227,11 +229,7 @@ public:
CompareTxMemPoolEntryByEntryTime
>
>
- {};
- typedef boost::multi_index_container<
- CTxMemPoolEntry,
- CTxMemPoolEntry_Indices
- > indexed_transaction_set;
+ >;
/**
* This mutex needs to be locked when accessing `mapTx` or other members
diff --git a/src/txrequest.cpp b/src/txrequest.cpp
index 4d7240be..53136a8e 100644
--- a/src/txrequest.cpp
+++ b/src/txrequest.cpp
@@ -208,17 +208,15 @@ struct ByTimeViewExtractor
}
};
-struct Announcement_Indices final : boost::multi_index::indexed_by<
- boost::multi_index::ordered_unique<boost::multi_index::tag<ByPeer>, ByPeerViewExtractor>,
- boost::multi_index::ordered_non_unique<boost::multi_index::tag<ByTxHash>, ByTxHashViewExtractor>,
- boost::multi_index::ordered_non_unique<boost::multi_index::tag<ByTime>, ByTimeViewExtractor>
->
-{};
/** Data type for the main data structure (Announcement objects with ByPeer/ByTxHash/ByTime indexes). */
using Index = boost::multi_index_container<
Announcement,
- Announcement_Indices
+ boost::multi_index::indexed_by<
+ boost::multi_index::ordered_unique<boost::multi_index::tag<ByPeer>, ByPeerViewExtractor>,
+ boost::multi_index::ordered_non_unique<boost::multi_index::tag<ByTxHash>, ByTxHashViewExtractor>,
+ boost::multi_index::ordered_non_unique<boost::multi_index::tag<ByTime>, ByTimeViewExtractor>
+ >
>;
/** Helper type to simplify syntax of iterator types. */
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.