From 8319a134684df2240057a5e8afaa6ae441fb8a58 Mon Sep 17 00:00:00 2001 From: Eugene Siegel Date: Fri, 18 Jul 2025 10:04:35 -0400 Subject: [PATCH] log: clarify RATELIMIT_MAX_BYTES comment, use RATELIMIT_WINDOW Co-Authored-By: stickies-v --- src/init.cpp | 2 +- src/logging.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index cc9f8160a3b..b48d3cc0710 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1384,7 +1384,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) LogInstance().SetRateLimiting(std::make_unique( [&scheduler](auto func, auto window) { scheduler.scheduleEvery(std::move(func), window); }, BCLog::RATELIMIT_MAX_BYTES, - 1h)); + BCLog::RATELIMIT_WINDOW)); assert(!node.validation_signals); node.validation_signals = std::make_unique(std::make_unique(scheduler)); diff --git a/src/logging.h b/src/logging.h index c753172545c..106de1f8d30 100644 --- a/src/logging.h +++ b/src/logging.h @@ -104,7 +104,8 @@ namespace BCLog { }; constexpr auto DEFAULT_LOG_LEVEL{Level::Debug}; constexpr size_t DEFAULT_MAX_LOG_BUFFER{1'000'000}; // buffer up to 1MB of log data prior to StartLogging - constexpr uint64_t RATELIMIT_MAX_BYTES{1024 * 1024}; // maximum number of bytes that can be logged within one window + constexpr uint64_t RATELIMIT_MAX_BYTES{1024 * 1024}; // maximum number of bytes per source location that can be logged within the RATELIMIT_WINDOW + constexpr auto RATELIMIT_WINDOW{1h}; // time window after which log ratelimit stats are reset //! Keeps track of an individual source location and how many available bytes are left for logging from it. class LogLimitStats