diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2018-08-12 21:41:44 +0000 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2018-09-09 12:01:43 +0000 |
commit | 50cb370d5babcef5caa9f90981c475ca5fe3f887 (patch) | |
tree | 5cc4ffccd3e16ffed4ce3eab797d948ddba7d10f /src/blockchain_utilities | |
parent | Merge pull request #4290 (diff) | |
download | monero-50cb370d5babcef5caa9f90981c475ca5fe3f887.tar.xz |
ringdb: allow blackballing many outputs at once
It cuts down on txn commits, and speeds up blackballing substantially
Diffstat (limited to 'src/blockchain_utilities')
-rw-r--r-- | src/blockchain_utilities/blockchain_blackball.cpp | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/blockchain_utilities/blockchain_blackball.cpp b/src/blockchain_utilities/blockchain_blackball.cpp index 1653910fc..04a894fe4 100644 --- a/src/blockchain_utilities/blockchain_blackball.cpp +++ b/src/blockchain_utilities/blockchain_blackball.cpp @@ -417,6 +417,7 @@ int main(int argc, char* argv[]) if (it != state.processed_heights.end()) start_idx = it->second; LOG_PRINT_L0("Reading blockchain from " << inputs[n] << " from " << start_idx); + std::vector<crypto::public_key> blackballs; for_all_transactions(inputs[n], start_idx, [&](const cryptonote::transaction_prefix &tx)->bool { for (const auto &in: tx.vin) @@ -439,7 +440,7 @@ int main(int argc, char* argv[]) { const crypto::public_key pkey = core_storage[n]->get_output_key(txin.amount, absolute[0]); MINFO("Blackballing output " << pkey << ", due to being used in a 1-ring"); - ringdb.blackball(pkey); + blackballs.push_back(pkey); newly_spent.insert(output_data(txin.amount, absolute[0])); } else if (state.ring_instances[new_ring] == new_ring.size()) @@ -448,7 +449,7 @@ int main(int argc, char* argv[]) { const crypto::public_key pkey = core_storage[n]->get_output_key(txin.amount, absolute[o]); MINFO("Blackballing output " << pkey << ", due to being used in " << new_ring.size() << " identical " << new_ring.size() << "-rings"); - ringdb.blackball(pkey); + blackballs.push_back(pkey); newly_spent.insert(output_data(txin.amount, absolute[o])); } } @@ -476,7 +477,7 @@ int main(int argc, char* argv[]) { const crypto::public_key pkey = core_storage[n]->get_output_key(txin.amount, common[0]); MINFO("Blackballing output " << pkey << ", due to being used in rings with a single common element"); - ringdb.blackball(pkey); + blackballs.push_back(pkey); newly_spent.insert(output_data(txin.amount, common[0])); } else @@ -490,6 +491,11 @@ int main(int argc, char* argv[]) } } state.relative_rings[txin.k_image] = new_ring; + if (!blackballs.empty()) + { + ringdb.blackball(blackballs); + blackballs.clear(); + } } if (stop_requested) { @@ -513,6 +519,7 @@ int main(int argc, char* argv[]) for (const auto &e: work_spent) state.spent.insert(e); + std::vector<crypto::public_key> blackballs; for (const output_data &od: work_spent) { for (const crypto::key_image &ki: state.outputs[od]) @@ -533,13 +540,19 @@ int main(int argc, char* argv[]) const crypto::public_key pkey = core_storage[0]->get_output_key(od.amount, last_unknown); MINFO("Blackballing output " << pkey << ", due to being used in a " << absolute.size() << "-ring where all other outputs are known to be spent"); - ringdb.blackball(pkey); + blackballs.push_back(pkey); newly_spent.insert(output_data(od.amount, last_unknown)); } } } } + if (!blackballs.empty()) + { + ringdb.blackball(blackballs); + blackballs.clear(); + } + LOG_PRINT_L0("Saving state data to " << state_file_path); std::ofstream state_data_out; state_data_out.open(state_file_path, std::ios_base::binary | std::ios_base::out | std::ios::trunc); |