Skip to content

Commit

Permalink
Revert "Print debug messages"
Browse files Browse the repository at this point in the history
This reverts commit d60a73f2544987f6df8045f4e096b855aad82f49.
  • Loading branch information
murchandamus committed Jan 4, 2024
1 parent e3a5b21 commit 195fe2d
Showing 1 changed file with 0 additions and 32 deletions.
32 changes: 0 additions & 32 deletions src/wallet/coinselection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,6 @@ util::Result<SelectionResult> CoinGrinder(std::vector<OutputGroup>& utxo_pool, c
total_available += utxo_pool[i].GetSelectionAmount();
min_group_weight = std::min(min_group_weight, utxo_pool[i].m_weight);
}

std::cout << "COINGRINDER START | selection_target: " << selection_target << ", change_target: " << change_target << ", utxo_count: " << utxo_pool.size() << std::endl;

if (total_available < selection_target + change_target) {
// Insufficient funds
return util::Error();
Expand Down Expand Up @@ -305,78 +302,52 @@ util::Result<SelectionResult> CoinGrinder(std::vector<OutputGroup>& utxo_pool, c
++curr_try;
++next_utxo;

std::cout << "Current Selection: " << curr_amount << " from [";
for (auto index : curr_selection) {
std::cout << index << ", " ;
}
std::cout << "]" << std::endl;

if (curr_amount + lookahead[curr_selection.back()] < selection_target + change_target) {
// Insufficient funds with lookahead: CUT
should_cut = true;
std::cout << "Insufficient funds in lookahead" << std::endl;
} else if (curr_weight > best_selection_weight) {
// best_selection_weight is initialized to max_weight
if (curr_weight > max_weight) max_tx_weight_exceeded = true;
// Worse weight than best solution. More UTXOs only increase weight:
// CUT if last selected group had minimal weight, else SHIFT
if (utxo_pool[curr_selection.back()].m_weight <= min_tail_weight[curr_selection.back()]) {
should_cut = true;
std::cout << "Best weight exceeded with min_weight" << std::endl;
} else {
should_shift = true;
std::cout << "Best weight exceeded with bigger weight" << std::endl;
}
} else if (curr_amount >= selection_target + change_target) {
// Potential solution, adding more weight cannot be better: SHIFT
should_shift = true;
std::cout << "Potential solution" << std::endl;
if (curr_weight < best_selection_weight || curr_amount < best_selection_amount) {
best_selection = curr_selection;
best_selection_weight = curr_weight;
best_selection_amount = curr_amount;
std::cout << "NEW BEST!" << std::endl;
}
}
if (next_utxo == utxo_pool.size()) {
// Reached end of UTXO pool, nothing left to add: CUT
should_cut = true;
std::cout << "Reached end of utxo pool, cutting" << std::endl;
}

if (should_cut) {
deselect_last();
should_shift = true;
should_cut = false;
std::cout << "CUT | ";
std::cout << "Current Selection: " << curr_amount << " from [";
for (auto index : curr_selection) {
std::cout << index << ", " ;
}
std::cout << "]" << std::endl;
}
if (should_shift) {
// Set `next_utxo` to one after last selected, deselect last selected UTXO, fallthrough to ADD
if (curr_selection.empty()) {
is_done = true;
std::cout << "Empty set in SHIFT, DONE" << std::endl;
result.SetAlgoCompleted(is_done);
break;
}
next_utxo = curr_selection.back() + 1;
deselect_last();
should_shift = false;
std::cout << "SHIFT";
std::cout << "Current Selection: " << curr_amount << " from [";
for (auto index : curr_selection) {
std::cout << index << ", " ;
}
std::cout << "]" << std::endl;
}

if (curr_try >= TOTAL_TRIES || is_done) {
// Solution is not guaranteed to be optimal if `curr_try` hit TOTAL_TRIES
std::cout << "DONE: total tries " << curr_try << std::endl;
result.SetAlgoCompleted(is_done);
break;
}
Expand All @@ -388,18 +359,15 @@ util::Result<SelectionResult> CoinGrinder(std::vector<OutputGroup>& utxo_pool, c
if (next_utxo < utxo_pool.size() - 1) {
// Skip if previous UTXO is equivalent and unselected
++next_utxo;
std::cout << "Skipping clone, next_utxo: " << next_utxo << std::endl;
} else {
// "Skipping" end of branch: SHIFT instead
if (curr_selection.empty()) {
is_done = true;
result.SetAlgoCompleted(is_done);
std::cout << "Empty selection in clone shifting--- DONE: total tries " << curr_try << std::endl;
break;
}
next_utxo = curr_selection.back() + 1;
deselect_last();
std::cout << "Skipping clone reached end of utxo pool, SHIFT" << std::endl;
}
}
}
Expand Down

0 comments on commit 195fe2d

Please sign in to comment.