With the new C++17 array deduction rules, an array encompassing all values in an enum can be specified in the same header file that specifies the enum. This is useful to avoid having to repeatedly enumerate all enum values in the code. E.g. the RPC code, but also the fuzz code.
Use C++17 std::array deduction for OUTPUT_TYPES, ALL_FEE_ESTIMATE_HORIZONS #20787
pull MarcoFalke wants to merge 2 commits into bitcoin:master from MarcoFalke:2012-WswitchFeeEstimateHorizon changing 6 files +19 −16-
MarcoFalke commented at 4:00 PM on December 28, 2020: member
- MarcoFalke added the label Refactoring on Dec 28, 2020
- MarcoFalke force-pushed on Dec 28, 2020
- MarcoFalke force-pushed on Dec 28, 2020
-
practicalswift commented at 9:06 PM on December 28, 2020: contributor
Concept ACK
- MarcoFalke force-pushed on Dec 28, 2020
-
mjdietzx commented at 3:35 AM on December 29, 2020: contributor
ack fa6a79d859c82c2efc0cf7227cea922d5fc5d55a
-
MarcoFalke commented at 7:57 AM on December 29, 2020: member
@mjdietzx Your
ackwon't get picked up by the merge script, btw. It needs to be any kind ofACK. -
jonatack commented at 8:21 AM on December 29, 2020: member
(@mjdietzx see https://github.com/bitcoin-core/bitcoin-maintainer-tools/pull/68 for context)
- vasild approved
-
vasild commented at 2:39 PM on December 29, 2020: member
ACK fa6a79d859c82c2efc0cf7227cea922d5fc5d55a
-
jonatack commented at 3:44 PM on December 29, 2020: member
ACK fa6a79d859c82c2efc0cf7227cea922d5fc5d55a
Thanks for the offline explanation @MarcoFalke on the differences between C++11 and C++17 std::array.
- theStack changes_requested
-
theStack commented at 5:01 PM on January 3, 2021: member
Concept ACK
There are two more instances where the
ALL_FEE_ESTIMATE_HORIZONSarray can be used now (found viagit grep SHORT_HALFLIFE):diff --git a/src/test/fuzz/policy_estimator.cpp b/src/test/fuzz/policy_estimator.cpp index 8a17a4b51..0562fc552 100644 --- a/src/test/fuzz/policy_estimator.cpp +++ b/src/test/fuzz/policy_estimator.cpp @@ -66,10 +66,10 @@ FUZZ_TARGET_INIT(policy_estimator, initialize_policy_estimator) } (void)block_policy_estimator.estimateFee(fuzzed_data_provider.ConsumeIntegral<int>()); EstimationResult result; - (void)block_policy_estimator.estimateRawFee(fuzzed_data_provider.ConsumeIntegral<int>(), fuzzed_data_provider.ConsumeFloatingPoint<double>(), fuzzed_data_provider.PickValueInArray({FeeEstimateHorizon::SHORT_HALFLIFE, FeeEstimateHorizon::MED_HALFLIFE, FeeEstimateHorizon::LONG_HALFLIFE}), fuzzed_data_provider.ConsumeBool() ? &result : nullptr); + (void)block_policy_estimator.estimateRawFee(fuzzed_data_provider.ConsumeIntegral<int>(), fuzzed_data_provider.ConsumeFloatingPoint<double>(), fuzzed_data_provider.PickValueInArray(ALL_FEE_ESTIMATE_HORIZONS), fuzzed_data_provider.ConsumeBool() ? &result : nullptr); FeeCalculation fee_calculation; (void)block_policy_estimator.estimateSmartFee(fuzzed_data_provider.ConsumeIntegral<int>(), fuzzed_data_provider.ConsumeBool() ? &fee_calculation : nullptr, fuzzed_data_provider.ConsumeBool()); - (void)block_policy_estimator.HighestTargetTracked(fuzzed_data_provider.PickValueInArray({FeeEstimateHorizon::SHORT_HALFLIFE, FeeEstimateHorizon::MED_HALFLIFE, FeeEstimateHorizon::LONG_HALFLIFE})); + (void)block_policy_estimator.HighestTargetTracked(fuzzed_data_provider.PickValueInArray(ALL_FEE_ESTIMATE_HORIZONS)); } { FuzzedAutoFileProvider fuzzed_auto_file_provider = ConsumeAutoFile(fuzzed_data_provider);(untested, don't have fuzzing activated in my current build configuration)
-
refactor: Use C++17 std::array deduction for OUTPUT_TYPES fa39cdd072
-
refactor: Use C++17 std::array deduction for ALL_FEE_ESTIMATE_HORIZONS aaaa987840
- MarcoFalke force-pushed on Jan 3, 2021
-
MarcoFalke commented at 5:40 PM on January 3, 2021: member
- theStack approved
-
theStack commented at 6:15 PM on January 3, 2021: member
cr ACK aaaa9878405f3f38f4f61c00feca110d7f9ca481 ⚙️
- fanquake approved
-
fanquake commented at 1:45 PM on January 11, 2021: member
ACK aaaa9878405f3f38f4f61c00feca110d7f9ca481
- fanquake merged this on Jan 11, 2021
- fanquake closed this on Jan 11, 2021
- MarcoFalke deleted the branch on Jan 11, 2021
- sidhujag referenced this in commit 791503bfb8 on Jan 11, 2021
- DrahtBot locked this on Aug 16, 2022
Labels