From a36591d1948359450746b1e7aa5da588c3a020eb Mon Sep 17 00:00:00 2001 From: Fabian Jahr Date: Sat, 27 Dec 2025 01:32:42 +0100 Subject: [PATCH] refactor: Use constexpr in torcontrol where possible --- src/torcontrol.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/torcontrol.cpp b/src/torcontrol.cpp index b948de3e5bc..9abc1fc032f 100644 --- a/src/torcontrol.cpp +++ b/src/torcontrol.cpp @@ -50,24 +50,24 @@ using util::ToString; /** Default control ip and port */ const std::string DEFAULT_TOR_CONTROL = "127.0.0.1:" + ToString(DEFAULT_TOR_CONTROL_PORT); /** Tor cookie size (from control-spec.txt) */ -static const int TOR_COOKIE_SIZE = 32; +constexpr int TOR_COOKIE_SIZE = 32; /** Size of client/server nonce for SAFECOOKIE */ -static const int TOR_NONCE_SIZE = 32; +constexpr int TOR_NONCE_SIZE = 32; /** For computing serverHash in SAFECOOKIE */ static const std::string TOR_SAFE_SERVERKEY = "Tor safe cookie authentication server-to-controller hash"; /** For computing clientHash in SAFECOOKIE */ static const std::string TOR_SAFE_CLIENTKEY = "Tor safe cookie authentication controller-to-server hash"; /** Exponential backoff configuration - initial timeout in seconds */ -static const float RECONNECT_TIMEOUT_START = 1.0; +constexpr float RECONNECT_TIMEOUT_START = 1.0; /** Exponential backoff configuration - growth factor */ -static const float RECONNECT_TIMEOUT_EXP = 1.5; +constexpr float RECONNECT_TIMEOUT_EXP = 1.5; /** Maximum reconnect timeout in seconds to prevent excessive delays */ -static const float RECONNECT_TIMEOUT_MAX = 600.0; +constexpr float RECONNECT_TIMEOUT_MAX = 600.0; /** Maximum length for lines received on TorControlConnection. * tor-control-spec.txt mentions that there is explicitly no limit defined to line length, * this is belt-and-suspenders sanity limit to prevent memory exhaustion. */ -static const int MAX_LINE_LENGTH = 100000; +constexpr int MAX_LINE_LENGTH = 100000; /****** Low-level TorControlConnection ********/