kernel: Add flushError method to notifications

This is done in addition with the following commit. Both have the goal
of getting rid of direct calls to AbortNode from kernel code. This extra
flushError method is added to notify specifically about errors that
arrise when flushing (syncing) block data to disk. Unlike other
instances, the current calls to AbortNode in the blockstorage flush
functions do not report an error to their callers.

This commit is part of the libbitcoinkernel project and further removes
the shutdown's and, more generally, the kernel library's dependency on
interface_ui with a kernel notification method. By removing interface_ui
from the kernel library, its dependency on boost is reduced to just
boost::multi_index. At the same time it also takes a step towards
de-globalising the interrupt infrastructure.
This commit is contained in:
TheCharlatan
2023-06-15 23:09:37 +02:00
parent 3fa9094b92
commit 7320db96f8
10 changed files with 35 additions and 3 deletions

View File

@@ -528,7 +528,7 @@ void BlockManager::FlushUndoFile(int block_file, bool finalize)
{
FlatFilePos undo_pos_old(block_file, m_blockfile_info[block_file].nUndoSize);
if (!UndoFileSeq().Flush(undo_pos_old, finalize)) {
AbortNode("Flushing undo file to disk failed. This is likely the result of an I/O error.");
m_opts.notifications.flushError("Flushing undo file to disk failed. This is likely the result of an I/O error.");
}
}
@@ -547,7 +547,7 @@ void BlockManager::FlushBlockFile(bool fFinalize, bool finalize_undo)
FlatFilePos block_pos_old(m_last_blockfile, m_blockfile_info[m_last_blockfile].nSize);
if (!BlockFileSeq().Flush(block_pos_old, fFinalize)) {
AbortNode("Flushing block file to disk failed. This is likely the result of an I/O error.");
m_opts.notifications.flushError("Flushing block file to disk failed. This is likely the result of an I/O error.");
}
// we do not always flush the undo file, as the chain tip may be lagging behind the incoming blocks,
// e.g. during IBD or a sync after a node going offline

View File

@@ -11,6 +11,7 @@
#include <common/args.h>
#include <common/system.h>
#include <node/interface_ui.h>
#include <shutdown.h>
#include <util/strencodings.h>
#include <util/string.h>
#include <util/translation.h>
@@ -72,4 +73,9 @@ void KernelNotifications::warning(const bilingual_str& warning)
DoWarning(warning);
}
void KernelNotifications::flushError(const std::string& debug_message)
{
AbortNode(debug_message);
}
} // namespace node

View File

@@ -25,6 +25,8 @@ public:
void progress(const bilingual_str& title, int progress_percent, bool resume_possible) override;
void warning(const bilingual_str& warning) override;
void flushError(const std::string& debug_message) override;
};
} // namespace node