diff options
author | furszy <matiasfurszyfer@protonmail.com> | 2023-02-13 19:56:26 -0300 |
---|---|---|
committer | furszy <matiasfurszyfer@protonmail.com> | 2023-03-08 10:15:06 -0300 |
commit | 805f399b174ef129ffabc07a87024be1ea1bfc35 (patch) | |
tree | b266d73489935fe130ac17bbff7159d13af04f17 /src/wallet/spend.cpp | |
parent | 8d12127a9c19cb218d661a88ab9b6871c9d853b9 (diff) | |
download | bitcoin-805f399b174ef129ffabc07a87024be1ea1bfc35.tar.xz |
wallet: do not make two COutputs, use shared_ptr
Diffstat (limited to 'src/wallet/spend.cpp')
-rw-r--r-- | src/wallet/spend.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/wallet/spend.cpp b/src/wallet/spend.cpp index a8ecce119a..0b58f99ce9 100644 --- a/src/wallet/spend.cpp +++ b/src/wallet/spend.cpp @@ -445,10 +445,10 @@ FilteredOutputGroups GroupOutputs(const CWallet& wallet, // OUTPUT_GROUP_MAX_ENTRIES COutputs, a new OutputGroup is added to the end of the vector. typedef std::map<std::pair<CScript, OutputType>, std::vector<OutputGroup>> ScriptPubKeyToOutgroup; const auto& group_outputs = []( - const COutput& output, OutputType type, size_t ancestors, size_t descendants, + const std::shared_ptr<COutput>& output, OutputType type, size_t ancestors, size_t descendants, ScriptPubKeyToOutgroup& groups_map, const CoinSelectionParams& coin_sel_params, bool positive_only) { - std::vector<OutputGroup>& groups = groups_map[std::make_pair(output.txout.scriptPubKey,type)]; + std::vector<OutputGroup>& groups = groups_map[std::make_pair(output->txout.scriptPubKey,type)]; if (groups.size() == 0) { // No OutputGroups for this scriptPubKey yet, add one @@ -468,8 +468,8 @@ FilteredOutputGroups GroupOutputs(const CWallet& wallet, } // Filter for positive only before adding the output to group - if (!positive_only || output.GetEffectiveValue() > 0) { - group->Insert(std::make_shared<COutput>(output), ancestors, descendants); + if (!positive_only || output->GetEffectiveValue() > 0) { + group->Insert(output, ancestors, descendants); } }; @@ -483,8 +483,9 @@ FilteredOutputGroups GroupOutputs(const CWallet& wallet, size_t ancestors, descendants; wallet.chain().getTransactionAncestry(output.outpoint.hash, ancestors, descendants); - group_outputs(output, type, ancestors, descendants, spk_to_groups_map, coin_sel_params, /*positive_only=*/ false); - group_outputs(output, type, ancestors, descendants, spk_to_positive_groups_map, + const auto& shared_output = std::make_shared<COutput>(output); + group_outputs(shared_output, type, ancestors, descendants, spk_to_groups_map, coin_sel_params, /*positive_only=*/ false); + group_outputs(shared_output, type, ancestors, descendants, spk_to_positive_groups_map, coin_sel_params, /*positive_only=*/ true); } } |