aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/coinselection.h
diff options
context:
space:
mode:
authorfurszy <matiasfurszyfer@protonmail.com>2022-08-01 16:15:36 -0300
committerfurszy <matiasfurszyfer@protonmail.com>2023-03-06 09:45:40 -0300
commit461f0821a2dff0a27f755464b0eb92314fba1acd (patch)
treed04797fd9b8cd29d0a0690af982d7f29547e0326 /src/wallet/coinselection.h
parentd8e749bb840cf65065ed00561998255156126278 (diff)
downloadbitcoin-461f0821a2dff0a27f755464b0eb92314fba1acd.tar.xz
refactor: make OutputGroup::m_outputs field a vector of shared_ptr
Initial steps towards sharing COutput instances across all possible OutputGroups (instead of copying them time after time).
Diffstat (limited to 'src/wallet/coinselection.h')
-rw-r--r--src/wallet/coinselection.h14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/wallet/coinselection.h b/src/wallet/coinselection.h
index 0e5e86f652..3ca6520242 100644
--- a/src/wallet/coinselection.h
+++ b/src/wallet/coinselection.h
@@ -198,7 +198,7 @@ struct CoinEligibilityFilter
struct OutputGroup
{
/** The list of UTXOs contained in this output group. */
- std::vector<COutput> m_outputs;
+ std::vector<std::shared_ptr<COutput>> m_outputs;
/** Whether the UTXOs were sent by the wallet to itself. This is relevant because we may want at
* least a certain number of confirmations on UTXOs received from outside wallets while trusting
* our own UTXOs more. */
@@ -237,7 +237,7 @@ struct OutputGroup
m_subtract_fee_outputs(params.m_subtract_fee_outputs)
{}
- void Insert(const COutput& output, size_t ancestors, size_t descendants);
+ void Insert(const std::shared_ptr<COutput>& output, size_t ancestors, size_t descendants);
bool EligibleForSpending(const CoinEligibilityFilter& eligibility_filter) const;
CAmount GetSelectionAmount() const;
};
@@ -259,7 +259,7 @@ struct OutputGroup
* @param[in] use_effective_value Whether to use the input's effective value (when true) or the real value (when false).
* @return The waste
*/
-[[nodiscard]] CAmount GetSelectionWaste(const std::set<COutput>& inputs, CAmount change_cost, CAmount target, bool use_effective_value = true);
+[[nodiscard]] CAmount GetSelectionWaste(const std::set<std::shared_ptr<COutput>>& inputs, CAmount change_cost, CAmount target, bool use_effective_value = true);
/** Choose a random change target for each transaction to make it harder to fingerprint the Core
@@ -292,7 +292,7 @@ struct SelectionResult
{
private:
/** Set of inputs selected by the algorithm to use in the transaction */
- std::set<COutput> m_selected_inputs;
+ std::set<std::shared_ptr<COutput>> m_selected_inputs;
/** The target the algorithm selected for. Equal to the recipient amount plus non-input fees */
CAmount m_target;
/** The algorithm used to produce this result */
@@ -329,7 +329,7 @@ public:
void Clear();
void AddInput(const OutputGroup& group);
- void AddInputs(const std::set<COutput>& inputs, bool subtract_fee_outputs);
+ void AddInputs(const std::set<std::shared_ptr<COutput>>& inputs, bool subtract_fee_outputs);
/** Calculates and stores the waste for this selection via GetSelectionWaste */
void ComputeAndSetWaste(const CAmount min_viable_change, const CAmount change_cost, const CAmount change_fee);
@@ -344,9 +344,9 @@ public:
void Merge(const SelectionResult& other);
/** Get m_selected_inputs */
- const std::set<COutput>& GetInputSet() const;
+ const std::set<std::shared_ptr<COutput>>& GetInputSet() const;
/** Get the vector of COutputs that will be used to fill in a CTransaction's vin */
- std::vector<COutput> GetShuffledInputVector() const;
+ std::vector<std::shared_ptr<COutput>> GetShuffledInputVector() const;
bool operator<(SelectionResult other) const;