diff --git a/src/wallet3/transaction_scanner.cpp b/src/wallet3/transaction_scanner.cpp index a0001e923ad..8608b52125b 100644 --- a/src/wallet3/transaction_scanner.cpp +++ b/src/wallet3/transaction_scanner.cpp @@ -34,6 +34,7 @@ namespace wallet // A derivation is simply the private view key multiplied by the tx public key // do this for every tx public key in the transaction + //TODO SEAN THIS IS A BOTTLENECK auto derivations = wallet_keys->generate_key_derivations(tx_public_keys); bool coinbase_transaction = cryptonote::is_coinbase(tx.tx); // Output belongs to public key derived as follows: @@ -55,6 +56,7 @@ namespace wallet std::optional sub_index{std::nullopt}; for (derivation_index = 0; derivation_index < derivations.size(); derivation_index++) { + //TODO SEAN THIS IS A BOTTLENECK sub_index = wallet_keys->output_and_derivation_ours( derivations[derivation_index], output_target->key, output_index); if (sub_index) diff --git a/src/wallet3/wallet.cpp b/src/wallet3/wallet.cpp index 48a2f784bc5..67b1d9c9d36 100644 --- a/src/wallet3/wallet.cpp +++ b/src/wallet3/wallet.cpp @@ -144,7 +144,6 @@ namespace wallet Wallet::add_block(const Block& block) { oxen::log::trace(logcat, "add block called with block height {}", block.height); - auto db_tx = db->db_transaction(); db->store_block(block); @@ -164,9 +163,7 @@ namespace wallet } } - db_tx.commit(); - last_scan_height++; } void @@ -185,11 +182,24 @@ namespace wallet return; } + std::vector threads; + + auto db_tx = db->db_transaction(); for (const auto& block : blocks) { if (block.height == last_scan_height + 1) - add_block(block); + { + threads.emplace_back([&]() { + add_block(block); + }); + last_scan_height++; + } } + // Wait for all threads to finish + for (auto& t : threads) { + t.join(); + } + db_tx.commit(); daemon_comms->register_wallet(*this, last_scan_height + 1 /*next needed block*/, false); }