Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add progress callbacks for file system actions. #421

Merged
merged 2 commits into from
Mar 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions include/bitcoin/database/impl/store.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
};
Expand Down Expand Up @@ -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_snapshot, table_t::store);

if (file::is_directory(primary))
{
// Delete /secondary, rename /primary to /secondary.
Expand All @@ -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
Expand Down Expand Up @@ -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());
};
Expand Down Expand Up @@ -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_snapshot, table_t::store);

if (file::is_directory(primary))
{
// Clear invalid /heads and recover from /primary.
Expand Down
9 changes: 6 additions & 3 deletions include/bitcoin/database/store.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_snapshot,

restore_table,
recover_snapshot
};

enum class table_t
Expand Down