aboutsummaryrefslogtreecommitdiff
path: root/src/blockchain_utilities
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2018-08-12 21:41:44 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2018-09-09 12:01:43 +0000
commit50cb370d5babcef5caa9f90981c475ca5fe3f887 (patch)
tree5cc4ffccd3e16ffed4ce3eab797d948ddba7d10f /src/blockchain_utilities
parentMerge pull request #4290 (diff)
downloadmonero-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.cpp21
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);