Skip to content

Commit

Permalink
Merge pull request #421 from evoskuil/master
Browse files Browse the repository at this point in the history
Add progress callbacks for file system actions.
  • Loading branch information
evoskuil authored Mar 16, 2024
2 parents 659dd0e + 9f93b0a commit 5a7d8d3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
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

0 comments on commit 5a7d8d3

Please sign in to comment.