Skip to content

Commit a3cb309

Browse files
committed
refactor: use recommended type hiding on multi_index types
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
1 parent 1016491 commit a3cb309

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
@@ -96,21 +96,25 @@ struct CompareTxIterByAncestorCount {
9696
}
9797
};
9898

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

116120
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
@@ -327,9 +327,7 @@ class CTxMemPool
327327

328328
static const int ROLLING_FEE_HALFLIFE = 60 * 60 * 12; // public only for testing
329329

330-
typedef boost::multi_index_container<
331-
CTxMemPoolEntry,
332-
boost::multi_index::indexed_by<
330+
struct CTxMemPoolEntry_Indices final : boost::multi_index::indexed_by<
333331
// sorted by txid
334332
boost::multi_index::hashed_unique<mempoolentry_txid, SaltedTxidHasher>,
335333
// sorted by wtxid
@@ -357,6 +355,10 @@ class CTxMemPool
357355
CompareTxMemPoolEntryByAncestorFee
358356
>
359357
>
358+
{};
359+
typedef boost::multi_index_container<
360+
CTxMemPoolEntry,
361+
CTxMemPoolEntry_Indices
360362
> indexed_transaction_set;
361363

362364
/**

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)