core: don't verify range proofs multiple times

This commit is contained in:
moneromooo-monero 2018-10-17 16:22:27 +00:00
parent 5c85da5a73
commit c39e0a1706
No known key found for this signature in database
GPG Key ID: 686F07454D6CEFC3
1 changed files with 6 additions and 1 deletions

View File

@ -856,16 +856,19 @@ namespace cryptonote
} }
waiter.wait(&tpool); waiter.wait(&tpool);
it = tx_blobs.begin(); it = tx_blobs.begin();
std::vector<bool> already_have(tx_blobs.size(), false);
for (size_t i = 0; i < tx_blobs.size(); i++, ++it) { for (size_t i = 0; i < tx_blobs.size(); i++, ++it) {
if (!results[i].res) if (!results[i].res)
continue; continue;
if(m_mempool.have_tx(results[i].hash)) if(m_mempool.have_tx(results[i].hash))
{ {
LOG_PRINT_L2("tx " << results[i].hash << "already have transaction in tx_pool"); LOG_PRINT_L2("tx " << results[i].hash << "already have transaction in tx_pool");
already_have[i] = true;
} }
else if(m_blockchain_storage.have_tx(results[i].hash)) else if(m_blockchain_storage.have_tx(results[i].hash))
{ {
LOG_PRINT_L2("tx " << results[i].hash << " already have transaction in blockchain"); LOG_PRINT_L2("tx " << results[i].hash << " already have transaction in blockchain");
already_have[i] = true;
} }
else else
{ {
@ -887,7 +890,7 @@ namespace cryptonote
std::vector<tx_verification_batch_info> tx_info; std::vector<tx_verification_batch_info> tx_info;
tx_info.reserve(tx_blobs.size()); tx_info.reserve(tx_blobs.size());
for (size_t i = 0; i < tx_blobs.size(); i++) { for (size_t i = 0; i < tx_blobs.size(); i++) {
if (!results[i].res) if (!results[i].res || already_have[i])
continue; continue;
tx_info.push_back({&results[i].tx, results[i].hash, tvc[i], results[i].res}); tx_info.push_back({&results[i].tx, results[i].hash, tvc[i], results[i].res});
} }
@ -897,6 +900,8 @@ namespace cryptonote
bool ok = true; bool ok = true;
it = tx_blobs.begin(); it = tx_blobs.begin();
for (size_t i = 0; i < tx_blobs.size(); i++, ++it) { for (size_t i = 0; i < tx_blobs.size(); i++, ++it) {
if (already_have[i])
continue;
if (!results[i].res) if (!results[i].res)
{ {
ok = false; ok = false;