Check if SelectionResult a is equivalent to SelectionResult b. * Equivalent means same input values, but maybe different inputs (i.e. same value, different prevout) */
| 114 | /** Check if SelectionResult a is equivalent to SelectionResult b. |
| 115 | * Equivalent means same input values, but maybe different inputs (i.e. same value, different prevout) */ |
| 116 | static bool EquivalentResult(const SelectionResult& a, const SelectionResult& b) |
| 117 | { |
| 118 | std::vector<CAmount> a_amts; |
| 119 | std::vector<CAmount> b_amts; |
| 120 | for (const auto& coin : a.GetInputSet()) { |
| 121 | a_amts.push_back(coin.txout.nValue.GetAmount()); |
| 122 | } |
| 123 | for (const auto& coin : b.GetInputSet()) { |
| 124 | b_amts.push_back(coin.txout.nValue.GetAmount()); |
| 125 | } |
| 126 | std::sort(a_amts.begin(), a_amts.end()); |
| 127 | std::sort(b_amts.begin(), b_amts.end()); |
| 128 | |
| 129 | std::pair<std::vector<CAmount>::iterator, std::vector<CAmount>::iterator> ret = std::mismatch(a_amts.begin(), a_amts.end(), b_amts.begin()); |
| 130 | return ret.first == a_amts.end() && ret.second == b_amts.end(); |
| 131 | } |
| 132 | |
| 133 | /** Check if this selection is equal to another one. Equal means same inputs (i.e same value and prevout) */ |
| 134 | static bool EqualResult(const SelectionResult& a, const SelectionResult& b) |
no test coverage detected