From 5762d82d2cc4031745db1f6519b4e05f268599a0 Mon Sep 17 00:00:00 2001 From: clemahieu Date: Tue, 25 Nov 2014 19:46:14 -0600 Subject: [PATCH] Using disk store for blocks instead of memory. --- rai/core/core.cpp | 14 +++++++------- rai/core/core.hpp | 1 - rai/qt/qt.cpp | 3 +-- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/rai/core/core.cpp b/rai/core/core.cpp index 21f5bdbb..03138304 100644 --- a/rai/core/core.cpp +++ b/rai/core/core.cpp @@ -2696,21 +2696,21 @@ void rai::block_path::generate (rai::block_hash const & hash_a) void rai::bulk_pull_client::process_end () { std::vector > path; - while (!blocks.empty ()) + while (connection->connection->client->store.bootstrap_begin () != connection->connection->client->store.bootstrap_end ()) { path.clear (); rai::block_path filler (path, [this] (rai::block_hash const & hash_a) { std::unique_ptr result; - auto existing (blocks.find (hash_a)); - if (existing != blocks.end ()) + auto block (connection->connection->client->store.bootstrap_get (hash_a)); + if (block != nullptr) { - result = std::move (existing->second); - blocks.erase (existing); + result = std::move (block); + connection->connection->client->store.bootstrap_del (hash_a); } return result; }); - filler.generate (blocks.begin ()->first); + filler.generate (connection->connection->client->store.bootstrap_begin ()->first); while (!path.empty ()) { auto process_result (connection->connection->client->processor.process_receive (*path.back ())); @@ -2742,7 +2742,7 @@ void rai::bulk_pull_client::received_block (boost::system::error_code const & ec if (block != nullptr) { auto hash (block->hash ()); - blocks [hash] = std::move (block); + connection->connection->client->store.bootstrap_put (hash, *block); receive_block (); } else diff --git a/rai/core/core.hpp b/rai/core/core.hpp index 10ba7c1d..b4882be2 100644 --- a/rai/core/core.hpp +++ b/rai/core/core.hpp @@ -451,7 +451,6 @@ namespace rai { void received_type (); void received_block (boost::system::error_code const &, size_t); void process_end (); - std::unordered_map > blocks; std::array receive_buffer; std::shared_ptr connection; std::unordered_map ::iterator current; diff --git a/rai/qt/qt.cpp b/rai/qt/qt.cpp index 583e83cb..2918fdba 100644 --- a/rai/qt/qt.cpp +++ b/rai/qt/qt.cpp @@ -101,9 +101,8 @@ wallet_add_account (new QPushButton ("Create account")) QPalette palette; palette.setColor (QPalette::Text, Qt::black); settings_connect_line->setPalette (palette); - settings_bootstrap_button->setEnabled (false); settings_bootstrap_button->setText ("Bootstrapping..."); - client_m.processor.bootstrap (endpoint, [this] () {settings_bootstrap_button->setText ("Bootstrap"); settings_bootstrap_button->setEnabled (true);}); + client_m.processor.bootstrap (endpoint); settings_connect_line->clear (); } else