Repository navigation
backport!: bitcoin#26347, #27199, #27279, #27622, #28067, #28602, #28863, #29115, #29260 #7711
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
9a55401
6c7d92b
1898d8f
32155d6
48a3b6c
13def7a
b42203e
bbb5992
0bc9aea
03ad3ec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| Wallet | ||
| ------ | ||
|
|
||
| - In the createwallet, loadwallet, unloadwallet, and restorewallet RPCs, the | ||
| "warning" string field is deprecated in favor of a "warnings" field that | ||
| returns a JSON array of strings to better handle multiple warning messages and | ||
| for consistency with other wallet RPCs. The "warning" field will be fully | ||
| removed from these RPCs in v25. It can be temporarily re-enabled during the | ||
| deprecation period by launching dashd with the configuration option | ||
| `-deprecatedrpc=walletwarningfield`. (dash#7711) |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -24,6 +24,7 @@ | |||||||||||||||||
|
|
||||||||||||||||||
| #include <algorithm> | ||||||||||||||||||
| #include <cassert> | ||||||||||||||||||
| #include <chrono> | ||||||||||||||||||
| #include <cmath> | ||||||||||||||||||
| #include <cstddef> | ||||||||||||||||||
| #include <cstdint> | ||||||||||||||||||
|
|
@@ -540,7 +541,7 @@ bool CBlockPolicyEstimator::_removeTx(const uint256& hash, bool inBlock) | |||||||||||||||||
| } | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| CBlockPolicyEstimator::CBlockPolicyEstimator(const fs::path& estimation_filepath) | ||||||||||||||||||
| CBlockPolicyEstimator::CBlockPolicyEstimator(const fs::path& estimation_filepath, const bool read_stale_estimates) | ||||||||||||||||||
| : m_estimation_filepath{estimation_filepath} | ||||||||||||||||||
| { | ||||||||||||||||||
| static_assert(MIN_BUCKET_FEERATE > 0, "Min feerate must be nonzero"); | ||||||||||||||||||
|
|
@@ -558,9 +559,22 @@ CBlockPolicyEstimator::CBlockPolicyEstimator(const fs::path& estimation_filepath | |||||||||||||||||
| shortStats = std::make_unique<TxConfirmStats>(buckets, bucketMap, SHORT_BLOCK_PERIODS, SHORT_DECAY, SHORT_SCALE); | ||||||||||||||||||
| longStats = std::make_unique<TxConfirmStats>(buckets, bucketMap, LONG_BLOCK_PERIODS, LONG_DECAY, LONG_SCALE); | ||||||||||||||||||
|
|
||||||||||||||||||
| // If the fee estimation file is present, read recorded estimations | ||||||||||||||||||
| AutoFile est_file{fsbridge::fopen(m_estimation_filepath, "rb")}; | ||||||||||||||||||
| if (est_file.IsNull() || !Read(est_file)) { | ||||||||||||||||||
|
|
||||||||||||||||||
| // Whenever the fee estimation file is not present return early | ||||||||||||||||||
| if (est_file.IsNull()) { | ||||||||||||||||||
| LogPrintf("%s is not found. Continue anyway.\n", fs::PathToString(m_estimation_filepath)); | ||||||||||||||||||
| return; | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| std::chrono::hours file_age = GetFeeEstimatorFileAge(); | ||||||||||||||||||
| // fee estimate file must not be too old to avoid wrong fee estimates. | ||||||||||||||||||
| if (file_age > MAX_FILE_AGE && !read_stale_estimates) { | ||||||||||||||||||
| LogPrintf("Fee estimation file %s too old (age=%lld > %lld hours) and will not be used to avoid serving stale estimates.\n", fs::PathToString(m_estimation_filepath), Ticks<std::chrono::hours>(file_age), Ticks<std::chrono::hours>(MAX_FILE_AGE)); | ||||||||||||||||||
| return; | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| if (!Read(est_file)) { | ||||||||||||||||||
| LogPrintf("Failed to read fee estimates from %s. Continue anyway.\n", fs::PathToString(m_estimation_filepath)); | ||||||||||||||||||
| } | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
@@ -915,10 +929,16 @@ CFeeRate CBlockPolicyEstimator::estimateSmartFee(int confTarget, FeeCalculation | |||||||||||||||||
|
|
||||||||||||||||||
| void CBlockPolicyEstimator::Flush() { | ||||||||||||||||||
| FlushUnconfirmed(); | ||||||||||||||||||
| FlushFeeEstimates(); | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| void CBlockPolicyEstimator::FlushFeeEstimates() | ||||||||||||||||||
| { | ||||||||||||||||||
| AutoFile est_file{fsbridge::fopen(m_estimation_filepath, "wb")}; | ||||||||||||||||||
| if (est_file.IsNull() || !Write(est_file)) { | ||||||||||||||||||
| LogPrintf("Failed to write fee estimates to %s. Continue anyway.\n", fs::PathToString(m_estimation_filepath)); | ||||||||||||||||||
| } else { | ||||||||||||||||||
| LogPrintf("Flushed fee estimates to %s.\n", fs::PathToString(m_estimation_filepath.filename())); | ||||||||||||||||||
| } | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
@@ -1022,3 +1042,10 @@ void CBlockPolicyEstimator::FlushUnconfirmed() | |||||||||||||||||
| const auto endclear{SteadyClock::now()}; | ||||||||||||||||||
| LogPrint(BCLog::ESTIMATEFEE, "Recorded %u unconfirmed txs from mempool in %gs\n", num_entries, Ticks<SecondsDouble>(endclear - startclear)); | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| std::chrono::hours CBlockPolicyEstimator::GetFeeEstimatorFileAge() | ||||||||||||||||||
| { | ||||||||||||||||||
| auto file_time = std::filesystem::last_write_time(m_estimation_filepath); | ||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win Handle file metadata errors without aborting startup.
Use the Proposed fix- auto file_time = std::filesystem::last_write_time(m_estimation_filepath);
+ std::error_code error;
+ auto file_time = std::filesystem::last_write_time(m_estimation_filepath, error);
+ if (error) {
+ LogPrintf("Failed to determine fee estimation file age for %s: %s\n",
+ fs::PathToString(m_estimation_filepath), error.message());
+ return std::chrono::hours::max();
+ }📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||
| auto now = std::filesystem::file_time_type::clock::now(); | ||||||||||||||||||
| return std::chrono::duration_cast<std::chrono::hours>(now - file_time); | ||||||||||||||||||
| } | ||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.