wallet: unify outputs grouping process

The 'GroupOutputs()' function performs the same
calculations for only-positive and mixed groups,
the only difference is that when we look for
only-positive groups, we discard negative utxos.

So, instead of wasting resources calling GroupOutputs()
for positive-only first, then call it again to include
the negative ones in the result, we can execute
GroupOutputs() only once, including in the response
both group types (positive-only and mixed).
This commit is contained in:
furszy
2022-08-02 11:54:20 -03:00
parent 55962001da
commit bd91ed1cb2
6 changed files with 143 additions and 71 deletions

View File

@@ -153,9 +153,9 @@ inline std::vector<OutputGroup>& KnapsackGroupOutputs(const CoinsResult& availab
/*tx_noinputs_size=*/ 0,
/*avoid_partial=*/ false,
};
static std::vector<OutputGroup> static_groups;
static_groups = GroupOutputs(wallet, available_coins.All(), coin_selection_params, filter, /*positive_only=*/false);
return static_groups;
static OutputGroupTypeMap static_groups;
static_groups = GroupOutputs(wallet, available_coins, coin_selection_params, {filter});
return static_groups.all_groups.mixed_group;
}
// Branch and bound coin selection tests