From 6cf8ca2a7f3e11ca5559018dfc9b20869c07cdce Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Tue, 30 Aug 2016 16:39:33 +0100 Subject: core: faster find_blockchain_supplement Since this queries block heights for blocks that may or may not exist, queries for non existing blocks would throw an exception, and that would slow down the loop a lot. 7 seconds to go through a 30 hash list. Fix this by adding an optional return block height to block_exists and using this instead. Actual errors will still throw an exception. This also cuts down on log exception spam. --- src/cryptonote_core/blockchain.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'src/cryptonote_core/blockchain.cpp') diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index 07db59796..dd9c21b91 100644 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -1801,12 +1801,8 @@ bool Blockchain::find_blockchain_supplement(const std::list& qbloc { try { - split_height = m_db->get_block_height(*bl_it); - break; - } - catch (const BLOCK_DNE& e) - { - continue; + if (m_db->block_exists(*bl_it, &split_height)) + break; } catch (const std::exception& e) { -- cgit v1.2.3