mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04:00
wallet: bugfix, 'CoinsResult::Erase' is erasing only one output of the set
The loop break shouldn't have being there.
Github-Pull: #26560
Rebased-From: f930aefff9
This commit is contained in:
parent
e5d097b639
commit
195f0dfd0e
2 changed files with 7 additions and 9 deletions
|
@ -102,15 +102,13 @@ void CoinsResult::Clear() {
|
||||||
coins.clear();
|
coins.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CoinsResult::Erase(std::set<COutPoint>& preset_coins)
|
void CoinsResult::Erase(const std::set<COutPoint>& coins_to_remove)
|
||||||
{
|
{
|
||||||
for (auto& it : coins) {
|
for (auto& [type, vec] : coins) {
|
||||||
auto& vec = it.second;
|
auto remove_it = std::remove_if(vec.begin(), vec.end(), [&](const COutput& coin) {
|
||||||
auto i = std::find_if(vec.begin(), vec.end(), [&](const COutput &c) { return preset_coins.count(c.outpoint);});
|
return coins_to_remove.count(coin.outpoint) == 1;
|
||||||
if (i != vec.end()) {
|
});
|
||||||
vec.erase(i);
|
vec.erase(remove_it, vec.end());
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ struct CoinsResult {
|
||||||
* i.e., methods can work with individual OutputType vectors or on the entire object */
|
* i.e., methods can work with individual OutputType vectors or on the entire object */
|
||||||
size_t Size() const;
|
size_t Size() const;
|
||||||
void Clear();
|
void Clear();
|
||||||
void Erase(std::set<COutPoint>& preset_coins);
|
void Erase(const std::set<COutPoint>& coins_to_remove);
|
||||||
void Shuffle(FastRandomContext& rng_fast);
|
void Shuffle(FastRandomContext& rng_fast);
|
||||||
void Add(OutputType type, const COutput& out);
|
void Add(OutputType type, const COutput& out);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue