mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-20 07:09:15 +01:00
validation: add randomness to periodic write interval
Co-Authored-By: Pieter Wuille <pieter@wuille.net> Co-Authored-By: l0rinc <pap.lorinc@gmail.com>
This commit is contained in:
@@ -90,8 +90,12 @@ using node::SnapshotMetadata;
|
||||
|
||||
/** Size threshold for warning about slow UTXO set flush to disk. */
|
||||
static constexpr size_t WARN_FLUSH_COINS_SIZE = 1 << 30; // 1 GiB
|
||||
/** Time to wait between writing blocks/block index and chainstate to disk. */
|
||||
static constexpr std::chrono::hours DATABASE_WRITE_INTERVAL{1};
|
||||
/** Time window to wait between writing blocks/block index and chainstate to disk.
|
||||
* Randomize writing time inside the window to prevent a situation where the
|
||||
* network over time settles into a few cohorts of synchronized writers.
|
||||
*/
|
||||
static constexpr auto DATABASE_WRITE_INTERVAL_MIN{50min};
|
||||
static constexpr auto DATABASE_WRITE_INTERVAL_MAX{70min};
|
||||
/** Maximum age of our tip for us to be considered current for fee estimation */
|
||||
static constexpr std::chrono::hours MAX_FEE_ESTIMATION_TIP_AGE{3};
|
||||
const std::vector<std::string> CHECKLEVEL_DOC {
|
||||
@@ -2945,7 +2949,8 @@ bool Chainstate::FlushStateToDisk(
|
||||
}
|
||||
|
||||
if (should_write || m_next_write == NodeClock::time_point::max()) {
|
||||
m_next_write = NodeClock::now() + DATABASE_WRITE_INTERVAL;
|
||||
constexpr auto range{DATABASE_WRITE_INTERVAL_MAX - DATABASE_WRITE_INTERVAL_MIN};
|
||||
m_next_write = FastRandomContext().rand_uniform_delay(NodeClock::now() + DATABASE_WRITE_INTERVAL_MIN, range);
|
||||
}
|
||||
}
|
||||
if (full_flush_completed && m_chainman.m_options.signals) {
|
||||
|
||||
Reference in New Issue
Block a user