From 6a302d40dfcc33b15bf27a1d3fcc04bfd3cbda44 Mon Sep 17 00:00:00 2001 From: furszy Date: Wed, 3 Aug 2022 19:04:36 -0300 Subject: wallet: single output groups filtering and grouping process Optimizes coin selection by performing the "group outputs" procedure only once, outside the "attempt selection" process. Avoiding the repeated execution of the 'GroupOutputs' operation that occurs on each coin eligibility filters (up to 8 of them); then for every coin vector type plus one for all the coins together. This also let us not perform coin selection over coin eligibility filtered groups that don't add new elements. (because, if the previous round failed, and the subsequent one has the same coins, then this new round will fail again). --- src/wallet/test/coinselector_tests.cpp | 2 +- src/wallet/test/group_outputs_tests.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/wallet/test') diff --git a/src/wallet/test/coinselector_tests.cpp b/src/wallet/test/coinselector_tests.cpp index 841d762932..8f626addde 100644 --- a/src/wallet/test/coinselector_tests.cpp +++ b/src/wallet/test/coinselector_tests.cpp @@ -154,7 +154,7 @@ inline std::vector& KnapsackGroupOutputs(const CoinsResult& availab /*avoid_partial=*/ false, }; static OutputGroupTypeMap static_groups; - static_groups = GroupOutputs(wallet, available_coins, coin_selection_params, {filter}); + static_groups = GroupOutputs(wallet, available_coins, coin_selection_params, {{filter}})[filter]; return static_groups.all_groups.mixed_group; } diff --git a/src/wallet/test/group_outputs_tests.cpp b/src/wallet/test/group_outputs_tests.cpp index 352ec44d5d..283e87989c 100644 --- a/src/wallet/test/group_outputs_tests.cpp +++ b/src/wallet/test/group_outputs_tests.cpp @@ -86,7 +86,7 @@ public: bool positive_only, int expected_size) { - OutputGroupTypeMap groups = GroupOutputs(*wallet, coins_pool, makeSelectionParams(rand, avoid_partial_spends), filter); + OutputGroupTypeMap groups = GroupOutputs(*wallet, coins_pool, makeSelectionParams(rand, avoid_partial_spends), {{filter}})[filter]; std::vector& groups_out = positive_only ? groups.groups_by_type[type].positive_group : groups.groups_by_type[type].mixed_group; BOOST_CHECK_EQUAL(groups_out.size(), expected_size); -- cgit v1.2.3