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
  1. MarcoFalke commented at 4:00 PM on December 28, 2020: member

    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.

  2. MarcoFalke added the label Refactoring on Dec 28, 2020
  3. MarcoFalke force-pushed on Dec 28, 2020
  4. MarcoFalke force-pushed on Dec 28, 2020
  5. practicalswift commented at 9:06 PM on December 28, 2020: contributor

    Concept ACK

  6. MarcoFalke force-pushed on Dec 28, 2020
  7. mjdietzx commented at 3:35 AM on December 29, 2020: contributor

    ack fa6a79d859c82c2efc0cf7227cea922d5fc5d55a

  8. MarcoFalke commented at 7:57 AM on December 29, 2020: member

    @mjdietzx Your ack won't get picked up by the merge script, btw. It needs to be any kind of ACK.

  9. jonatack commented at 8:21 AM on December 29, 2020: member
  10. vasild approved
  11. vasild commented at 2:39 PM on December 29, 2020: member

    ACK fa6a79d859c82c2efc0cf7227cea922d5fc5d55a

  12. 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.

  13. theStack changes_requested
  14. theStack commented at 5:01 PM on January 3, 2021: member

    Concept ACK

    There are two more instances where the ALL_FEE_ESTIMATE_HORIZONS array can be used now (found via git 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)

  15. refactor: Use C++17 std::array deduction for OUTPUT_TYPES fa39cdd072
  16. refactor: Use C++17 std::array deduction for ALL_FEE_ESTIMATE_HORIZONS aaaa987840
  17. MarcoFalke force-pushed on Jan 3, 2021
  18. MarcoFalke commented at 5:40 PM on January 3, 2021: member

    Rebased on the already merged #20812 to fix the feedback by @theStack

  19. theStack approved
  20. theStack commented at 6:15 PM on January 3, 2021: member

    cr ACK aaaa9878405f3f38f4f61c00feca110d7f9ca481 ⚙️

  21. fanquake approved
  22. fanquake commented at 1:45 PM on January 11, 2021: member

    ACK aaaa9878405f3f38f4f61c00feca110d7f9ca481

  23. fanquake merged this on Jan 11, 2021
  24. fanquake closed this on Jan 11, 2021

  25. MarcoFalke deleted the branch on Jan 11, 2021
  26. sidhujag referenced this in commit 791503bfb8 on Jan 11, 2021
  27. DrahtBot locked this on Aug 16, 2022

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-17 06:14 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me