diff options
Diffstat (limited to 'src/blockchain_utilities/blockchain_blackball.cpp')
-rw-r--r-- | src/blockchain_utilities/blockchain_blackball.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/blockchain_utilities/blockchain_blackball.cpp b/src/blockchain_utilities/blockchain_blackball.cpp index 52d2938cd..1653910fc 100644 --- a/src/blockchain_utilities/blockchain_blackball.cpp +++ b/src/blockchain_utilities/blockchain_blackball.cpp @@ -404,6 +404,11 @@ int main(int argc, char* argv[]) cryptonote::block b = core_storage[0]->get_db().get_block_from_height(0); tools::ringdb ringdb(output_file_path.string(), epee::string_tools::pod_to_hex(get_block_hash(b))); + bool stop_requested = false; + tools::signal_handler::install([&stop_requested](int type) { + stop_requested = true; + }); + for (size_t n = 0; n < inputs.size(); ++n) { const std::string canonical = boost::filesystem::canonical(inputs[n]).string(); @@ -436,7 +441,6 @@ int main(int argc, char* argv[]) MINFO("Blackballing output " << pkey << ", due to being used in a 1-ring"); ringdb.blackball(pkey); newly_spent.insert(output_data(txin.amount, absolute[0])); - state.spent.insert(output_data(txin.amount, absolute[0])); } else if (state.ring_instances[new_ring] == new_ring.size()) { @@ -446,7 +450,6 @@ int main(int argc, char* argv[]) MINFO("Blackballing output " << pkey << ", due to being used in " << new_ring.size() << " identical " << new_ring.size() << "-rings"); ringdb.blackball(pkey); newly_spent.insert(output_data(txin.amount, absolute[o])); - state.spent.insert(output_data(txin.amount, absolute[o])); } } else if (state.relative_rings.find(txin.k_image) != state.relative_rings.end()) @@ -475,7 +478,6 @@ int main(int argc, char* argv[]) MINFO("Blackballing output " << pkey << ", due to being used in rings with a single common element"); ringdb.blackball(pkey); newly_spent.insert(output_data(txin.amount, common[0])); - state.spent.insert(output_data(txin.amount, common[0])); } else { @@ -489,9 +491,17 @@ int main(int argc, char* argv[]) } state.relative_rings[txin.k_image] = new_ring; } + if (stop_requested) + { + MINFO("Stopping scan, secondary passes will still happen..."); + return false; + } return true; }); + LOG_PRINT_L0("blockchain from " << inputs[n] << " processed still height " << start_idx); state.processed_heights[canonical] = start_idx; + if (stop_requested) + break; } while (!newly_spent.empty()) @@ -500,6 +510,9 @@ int main(int argc, char* argv[]) std::unordered_set<output_data> work_spent = std::move(newly_spent); newly_spent.clear(); + for (const auto &e: work_spent) + state.spent.insert(e); + for (const output_data &od: work_spent) { for (const crypto::key_image &ki: state.outputs[od]) @@ -522,7 +535,6 @@ int main(int argc, char* argv[]) absolute.size() << "-ring where all other outputs are known to be spent"); ringdb.blackball(pkey); newly_spent.insert(output_data(od.amount, last_unknown)); - state.spent.insert(output_data(od.amount, last_unknown)); } } } |