From 53e1f2f86dce3954424788b9fd5a9f7125e3ed08 Mon Sep 17 00:00:00 2001 From: evoskuil Date: Sat, 16 Mar 2024 00:58:14 -0400 Subject: [PATCH 1/2] Add progress callbacks for file system actions. --- include/bitcoin/database/impl/store.ipp | 9 +++++++-- include/bitcoin/database/store.hpp | 9 ++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/include/bitcoin/database/impl/store.ipp b/include/bitcoin/database/impl/store.ipp index 58e55ef3..adb95b3a 100644 --- a/include/bitcoin/database/impl/store.ipp +++ b/include/bitcoin/database/impl/store.ipp @@ -303,7 +303,7 @@ code CLASS::snapshot(const event_handler& handler) NOEXCEPT { if (!ec) { - handler(event_t::flush_table, table); + handler(event_t::flush_body, table); ec = storage.flush(); } }; @@ -619,6 +619,8 @@ code CLASS::backup(const event_handler& handler) NOEXCEPT static const auto primary = configuration_.path / schema::dir::primary; static const auto secondary = configuration_.path / schema::dir::secondary; + handler(event_t::archive_index, table_t::store); + if (file::is_directory(primary)) { // Delete /secondary, rename /primary to /secondary. @@ -635,6 +637,7 @@ code CLASS::backup(const event_handler& handler) NOEXCEPT } // Dump memory maps of /heads to new files in /primary. +// Heads are copied from RAM, not flushed to disk and copied as files. TEMPLATE code CLASS::dump(const path& folder, const event_handler& handler) NOEXCEPT @@ -682,7 +685,7 @@ code CLASS::dump(const path& folder, const auto dump = [&handler, &folder](const auto& storage, const auto& name, table_t table) NOEXCEPT { - handler(event_t::dump_table, table); + handler(event_t::copy_header, table); return file::create_file(head(folder, name), storage->begin(), storage->size()); }; @@ -751,6 +754,8 @@ code CLASS::restore(const event_handler& handler) NOEXCEPT static const auto primary = configuration_.path / schema::dir::primary; static const auto secondary = configuration_.path / schema::dir::secondary; + handler(event_t::recover_index, table_t::store); + if (file::is_directory(primary)) { // Clear invalid /heads and recover from /primary. diff --git a/include/bitcoin/database/store.hpp b/include/bitcoin/database/store.hpp index 2099bcd4..d0e2f4c4 100644 --- a/include/bitcoin/database/store.hpp +++ b/include/bitcoin/database/store.hpp @@ -46,10 +46,13 @@ enum class event_t close_table, wait_lock, - flush_table, + flush_body, backup_table, - dump_table, - restore_table + copy_header, + archive_index, + + restore_table, + recover_index }; enum class table_t From 9f93b0a0037ff436232f83570b2be2f7672741d9 Mon Sep 17 00:00:00 2001 From: evoskuil Date: Sat, 16 Mar 2024 01:05:34 -0400 Subject: [PATCH 2/2] Rename _index to _snapshot. --- include/bitcoin/database/impl/store.ipp | 4 ++-- include/bitcoin/database/store.hpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/bitcoin/database/impl/store.ipp b/include/bitcoin/database/impl/store.ipp index adb95b3a..02a3a7f2 100644 --- a/include/bitcoin/database/impl/store.ipp +++ b/include/bitcoin/database/impl/store.ipp @@ -619,7 +619,7 @@ code CLASS::backup(const event_handler& handler) NOEXCEPT static const auto primary = configuration_.path / schema::dir::primary; static const auto secondary = configuration_.path / schema::dir::secondary; - handler(event_t::archive_index, table_t::store); + handler(event_t::archive_snapshot, table_t::store); if (file::is_directory(primary)) { @@ -754,7 +754,7 @@ code CLASS::restore(const event_handler& handler) NOEXCEPT static const auto primary = configuration_.path / schema::dir::primary; static const auto secondary = configuration_.path / schema::dir::secondary; - handler(event_t::recover_index, table_t::store); + handler(event_t::recover_snapshot, table_t::store); if (file::is_directory(primary)) { diff --git a/include/bitcoin/database/store.hpp b/include/bitcoin/database/store.hpp index d0e2f4c4..bdb5d0c8 100644 --- a/include/bitcoin/database/store.hpp +++ b/include/bitcoin/database/store.hpp @@ -49,10 +49,10 @@ enum class event_t flush_body, backup_table, copy_header, - archive_index, + archive_snapshot, restore_table, - recover_index + recover_snapshot }; enum class table_t