Skip to content

Commit 0f68a05

Browse files
committed
Merge bitcoin/bitcoin#30194: refactor: use recommended type hiding on multi_index types
a3cb309 refactor: use recommended type hiding on multi_index types (Cory Fields) Pull request description: Recommended by boost docs: https://www.boost.org/doc/libs/1_85_0/libs/multi_index/doc/compiler_specifics.html#type_hiding This significantly reduces the size of the symbol name lengths that end up in the binaries as well as in compiler warnings/errors. Otherwise there should be no functional change. Example before: > 0000000000000000 W unsigned long boost::multi_index::detail::hashed_index<mempoolentry_txid, SaltedTxidHasher, std::equal_to<uint256>, boost::multi_index::detail::nth_layer<1, CTxMemPoolEntry, boost::multi_index::indexed_by<boost::multi_index::hashed_unique<mempoolentry_txid, SaltedTxidHasher, mpl_::na, mpl_::na>, boost::multi_index::hashed_unique<boost::multi_index::tag<index_by_wtxid, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, mempoolentry_wtxid, SaltedTxidHasher, mpl_::na>, boost::multi_index::ordered_non_unique<boost::multi_index::tag<descendant_score, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, boost::multi_index::identity<CTxMemPoolEntry>, CompareTxMemPoolEntryByDescendantScore>, boost::multi_index::ordered_non_unique<boost::multi_index::tag<entry_time, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, boost::multi_index::identity<CTxMemPoolEntry>, CompareTxMemPoolEntryByEntryTime>, boost::multi_index::ordered_non_unique<boost::multi_index::tag<ancestor_score, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, boost::multi_index::identity<CTxMemPoolEntry>, CompareTxMemPoolEntryByAncestorFee>, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, std::allocator<CTxMemPoolEntry> >, boost::mpl::vector0<mpl_::na>, boost::multi_index::detail::hashed_unique_tag>::count<uint256, SaltedTxidHasher, std::equal_to<uint256> >(uint256 const&, SaltedTxidHasher const&, std::equal_to<uint256> const&, mpl_::bool_<false>) const After: > 0000000000000000 W unsigned long boost::multi_index::detail::hashed_index<mempoolentry_txid, SaltedTxidHasher, std::equal_to<uint256>, boost::multi_index::detail::nth_layer<1, CTxMemPoolEntry, CTxMemPool::CTxMemPoolEntry_Indicies, std::allocator<CTxMemPoolEntry> >, boost::mpl::vector0<mpl_::na>, boost::multi_index::detail::hashed_unique_tag>::count<uint256, SaltedTxidHasher, std::equal_to<uint256> >(uint256 const&, SaltedTxidHasher const&, std::equal_to<uint256> const&, mpl_::bool_<false>) const ACKs for top commit: glozow: ACK a3cb309, TIL, makes sense to me TheCharlatan: ACK a3cb309 fanquake: ACK a3cb309 Tree-SHA512: f6bb3d133daec126cf064ed6fe4457f457c0cfdbea28778c8ff426be7b41b271ada2d790c6b4129ca22156182c99aaf287e3aa9fb6b076ee55946da40e06e5d8
2 parents da083d4 + a3cb309 commit 0f68a05

File tree

3 files changed

+30
-21
lines changed

3 files changed

+30
-21
lines changed

src/node/miner.h

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -97,21 +97,25 @@ struct CompareTxIterByAncestorCount {
9797
}
9898
};
9999

100+
101+
struct CTxMemPoolModifiedEntry_Indices final : boost::multi_index::indexed_by<
102+
boost::multi_index::ordered_unique<
103+
modifiedentry_iter,
104+
CompareCTxMemPoolIter
105+
>,
106+
// sorted by modified ancestor fee rate
107+
boost::multi_index::ordered_non_unique<
108+
// Reuse same tag from CTxMemPool's similar index
109+
boost::multi_index::tag<ancestor_score>,
110+
boost::multi_index::identity<CTxMemPoolModifiedEntry>,
111+
CompareTxMemPoolEntryByAncestorFee
112+
>
113+
>
114+
{};
115+
100116
typedef boost::multi_index_container<
101117
CTxMemPoolModifiedEntry,
102-
boost::multi_index::indexed_by<
103-
boost::multi_index::ordered_unique<
104-
modifiedentry_iter,
105-
CompareCTxMemPoolIter
106-
>,
107-
// sorted by modified ancestor fee rate
108-
boost::multi_index::ordered_non_unique<
109-
// Reuse same tag from CTxMemPool's similar index
110-
boost::multi_index::tag<ancestor_score>,
111-
boost::multi_index::identity<CTxMemPoolModifiedEntry>,
112-
CompareTxMemPoolEntryByAncestorFee
113-
>
114-
>
118+
CTxMemPoolModifiedEntry_Indices
115119
> indexed_modified_transaction_set;
116120

117121
typedef indexed_modified_transaction_set::nth_index<0>::type::iterator modtxiter;

src/txmempool.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -329,9 +329,7 @@ class CTxMemPool
329329

330330
static const int ROLLING_FEE_HALFLIFE = 60 * 60 * 12; // public only for testing
331331

332-
typedef boost::multi_index_container<
333-
CTxMemPoolEntry,
334-
boost::multi_index::indexed_by<
332+
struct CTxMemPoolEntry_Indices final : boost::multi_index::indexed_by<
335333
// sorted by txid
336334
boost::multi_index::hashed_unique<mempoolentry_txid, SaltedTxidHasher>,
337335
// sorted by wtxid
@@ -359,6 +357,10 @@ class CTxMemPool
359357
CompareTxMemPoolEntryByAncestorFee
360358
>
361359
>
360+
{};
361+
typedef boost::multi_index_container<
362+
CTxMemPoolEntry,
363+
CTxMemPoolEntry_Indices
362364
> indexed_transaction_set;
363365

364366
/**

src/txrequest.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -212,14 +212,17 @@ struct ByTimeViewExtractor
212212
}
213213
};
214214

215+
struct Announcement_Indices final : boost::multi_index::indexed_by<
216+
boost::multi_index::ordered_unique<boost::multi_index::tag<ByPeer>, ByPeerViewExtractor>,
217+
boost::multi_index::ordered_non_unique<boost::multi_index::tag<ByTxHash>, ByTxHashViewExtractor>,
218+
boost::multi_index::ordered_non_unique<boost::multi_index::tag<ByTime>, ByTimeViewExtractor>
219+
>
220+
{};
221+
215222
/** Data type for the main data structure (Announcement objects with ByPeer/ByTxHash/ByTime indexes). */
216223
using Index = boost::multi_index_container<
217224
Announcement,
218-
boost::multi_index::indexed_by<
219-
boost::multi_index::ordered_unique<boost::multi_index::tag<ByPeer>, ByPeerViewExtractor>,
220-
boost::multi_index::ordered_non_unique<boost::multi_index::tag<ByTxHash>, ByTxHashViewExtractor>,
221-
boost::multi_index::ordered_non_unique<boost::multi_index::tag<ByTime>, ByTimeViewExtractor>
222-
>
225+
Announcement_Indices
223226
>;
224227

225228
/** Helper type to simplify syntax of iterator types. */

0 commit comments

Comments
 (0)