mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-18 13:17:55 +02:00
Merge 04265ba937 into merged_master (Bitcoin PR bitcoin/bitcoin#26331)
This commit is contained in:
commit
d9e1e28421
3 changed files with 23 additions and 3 deletions
|
|
@ -443,11 +443,13 @@ const Coin& AccessByTxid(const CCoinsViewCache& view, const uint256& txid)
|
|||
return coinEmpty;
|
||||
}
|
||||
|
||||
bool CCoinsViewErrorCatcher::GetCoin(const COutPoint &outpoint, Coin &coin) const {
|
||||
template <typename Func>
|
||||
static bool ExecuteBackedWrapper(Func func, const std::vector<std::function<void()>>& err_callbacks)
|
||||
{
|
||||
try {
|
||||
return CCoinsViewBacked::GetCoin(outpoint, coin);
|
||||
return func();
|
||||
} catch(const std::runtime_error& e) {
|
||||
for (const auto& f : m_err_callbacks) {
|
||||
for (const auto& f : err_callbacks) {
|
||||
f();
|
||||
}
|
||||
LogPrintf("Error reading from database: %s\n", e.what());
|
||||
|
|
@ -458,3 +460,11 @@ bool CCoinsViewErrorCatcher::GetCoin(const COutPoint &outpoint, Coin &coin) cons
|
|||
std::abort();
|
||||
}
|
||||
}
|
||||
|
||||
bool CCoinsViewErrorCatcher::GetCoin(const COutPoint &outpoint, Coin &coin) const {
|
||||
return ExecuteBackedWrapper([&]() { return CCoinsViewBacked::GetCoin(outpoint, coin); }, m_err_callbacks);
|
||||
}
|
||||
|
||||
bool CCoinsViewErrorCatcher::HaveCoin(const COutPoint &outpoint) const {
|
||||
return ExecuteBackedWrapper([&]() { return CCoinsViewBacked::HaveCoin(outpoint); }, m_err_callbacks);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -400,6 +400,7 @@ public:
|
|||
}
|
||||
|
||||
bool GetCoin(const COutPoint &outpoint, Coin &coin) const override;
|
||||
bool HaveCoin(const COutPoint &outpoint) const override;
|
||||
|
||||
private:
|
||||
/** A list of callbacks to execute upon leveldb read error. */
|
||||
|
|
|
|||
|
|
@ -1275,6 +1275,15 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
|||
RandAddPeriodic();
|
||||
}, std::chrono::minutes{1});
|
||||
|
||||
// Check disk space every 5 minutes to avoid db corruption.
|
||||
node.scheduler->scheduleEvery([&args]{
|
||||
constexpr uint64_t min_disk_space = 50 << 20; // 50 MB
|
||||
if (!CheckDiskSpace(args.GetBlocksDirPath(), min_disk_space)) {
|
||||
LogPrintf("Shutting down due to lack of disk space!\n");
|
||||
StartShutdown();
|
||||
}
|
||||
}, std::chrono::minutes{5});
|
||||
|
||||
GetMainSignals().RegisterBackgroundSignalScheduler(*node.scheduler);
|
||||
|
||||
// Create client interfaces for wallets that are supposed to be loaded
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue