54 | @@ -55,10 +55,18 @@ FUZZ_TARGET(txorphan, .init = initialize_orphanage)
55 | const auto num_out = fuzzed_data_provider.ConsumeIntegralInRange<uint32_t>(1, 256);
56 | // pick outpoints from outpoints as input. We allow input duplicates on purpose, given we are not
57 | // running any transaction validation logic before adding transactions to the orphanage
58 | - for (uint32_t i = 0; i < num_in; i++) {
59 | - auto& prevout = PickValue(fuzzed_data_provider, outpoints);
60 | - // try making transactions unique by setting a random nSequence, but allow duplicate transactions if they happen
61 | - tx_mut.vin.emplace_back(prevout, CScript{}, fuzzed_data_provider.ConsumeIntegralInRange<uint32_t>(0, CTxIn::SEQUENCE_FINAL));
62 | + {
63 | + // Create copy of set to allow fast PickValue
Perhaps a more descriptive comment would be good, e.g.: We don't call PickValue on the outpoints set directly because PickValue will advance a begin iterator on the set, which is expensive, because it only has a "++" operator. As it would be called in a loop of num_in (~outpoints.size()), the runtime would be O(outpoints.size() ^ 2). Instead we create a std::vector copy of the set, which allows for O(1) std::advance..