MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / PickRandomTx

Method PickRandomTx

src/cluster_linearize.h:790–800  ·  view source on GitHub ↗

Pick a random transaction within a set (which must be non-empty). */

Source from the content-addressed store, hash-verified

788
789 /** Pick a random transaction within a set (which must be non-empty). */
790 TxIdx PickRandomTx(const SetType& tx_idxs) noexcept
791 {
792 Assume(tx_idxs.Any());
793 unsigned pos = m_rng.randrange<unsigned>(tx_idxs.Count());
794 for (auto tx_idx : tx_idxs) {
795 if (pos == 0) return tx_idx;
796 --pos;
797 }
798 Assume(false);
799 return TxIdx(-1);
800 }
801
802 /** Find the set of out-of-chunk transactions reachable from tx_idxs, both in upwards and
803 * downwards direction. Only used by SanityCheck to verify the precomputed reachable sets in

Callers

nothing calls this directly

Calls 2

AnyMethod · 0.45
CountMethod · 0.45

Tested by

no test coverage detected