aboutsummaryrefslogtreecommitdiff
path: root/src/node
diff options
context:
space:
mode:
authorTheCharlatan <seb.kung@gmail.com>2023-06-15 23:09:37 +0200
committerTheCharlatan <seb.kung@gmail.com>2023-06-28 09:52:32 +0200
commit7320db96f8d2aeff0bc5dc67d8b7b37f5f808990 (patch)
tree6a15f7fac466f6c0d4dc75ff05a9b52205c1102f /src/node
parent3fa9094b92c5d37f486b0f8265062d3456796a50 (diff)
downloadbitcoin-7320db96f8d2aeff0bc5dc67d8b7b37f5f808990.tar.xz
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.
Diffstat (limited to 'src/node')
-rw-r--r--src/node/blockstorage.cpp4
-rw-r--r--src/node/kernel_notifications.cpp6
-rw-r--r--src/node/kernel_notifications.h2
3 files changed, 10 insertions, 2 deletions
diff --git a/src/node/blockstorage.cpp b/src/node/blockstorage.cpp
index a27a7a5466..729ac8850a 100644
--- a/src/node/blockstorage.cpp
+++ b/src/node/blockstorage.cpp
@@ -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
diff --git a/src/node/kernel_notifications.cpp b/src/node/kernel_notifications.cpp
index 926b157f3b..7c7db26e9b 100644
--- a/src/node/kernel_notifications.cpp
+++ b/src/node/kernel_notifications.cpp
@@ -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
diff --git a/src/node/kernel_notifications.h b/src/node/kernel_notifications.h
index 3e665bbf14..fa80af1120 100644
--- a/src/node/kernel_notifications.h
+++ b/src/node/kernel_notifications.h
@@ -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