mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-06-02 15:32:34 +02:00
Merge 26331 via origin-pull/26331/head
This commit is contained in:
commit
b54d824dcf
@ -348,11 +348,13 @@ const Coin& AccessByTxid(const CCoinsViewCache& view, const uint256& txid)
|
|||||||
return coinEmpty;
|
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 {
|
try {
|
||||||
return CCoinsViewBacked::GetCoin(outpoint, coin);
|
return func();
|
||||||
} catch(const std::runtime_error& e) {
|
} catch(const std::runtime_error& e) {
|
||||||
for (const auto& f : m_err_callbacks) {
|
for (const auto& f : err_callbacks) {
|
||||||
f();
|
f();
|
||||||
}
|
}
|
||||||
LogPrintf("Error reading from database: %s\n", e.what());
|
LogPrintf("Error reading from database: %s\n", e.what());
|
||||||
@ -363,3 +365,11 @@ bool CCoinsViewErrorCatcher::GetCoin(const COutPoint &outpoint, Coin &coin) cons
|
|||||||
std::abort();
|
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);
|
||||||
|
}
|
||||||
|
@ -365,6 +365,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool GetCoin(const COutPoint &outpoint, Coin &coin) const override;
|
bool GetCoin(const COutPoint &outpoint, Coin &coin) const override;
|
||||||
|
bool HaveCoin(const COutPoint &outpoint) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/** A list of callbacks to execute upon leveldb read error. */
|
/** A list of callbacks to execute upon leveldb read error. */
|
||||||
|
@ -1159,6 +1159,15 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
|||||||
RandAddPeriodic();
|
RandAddPeriodic();
|
||||||
}, std::chrono::minutes{1});
|
}, 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);
|
GetMainSignals().RegisterBackgroundSignalScheduler(*node.scheduler);
|
||||||
|
|
||||||
// Create client interfaces for wallets that are supposed to be loaded
|
// Create client interfaces for wallets that are supposed to be loaded
|
||||||
|
Loading…
Reference in New Issue
Block a user