Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F12944966
D13003.id37587.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Subscribers
None
D13003.id37587.diff
View Options
diff --git a/src/avalanche/statistics.h b/src/avalanche/statistics.h
new file mode 100644
--- /dev/null
+++ b/src/avalanche/statistics.h
@@ -0,0 +1,22 @@
+// Copyright (c) 2023 The Bitcoin developers
+// Distributed under the MIT software license, see the accompanying
+// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
+#ifndef BITCOIN_AVALANCHE_STATISTICS_H
+#define BITCOIN_AVALANCHE_STATISTICS_H
+
+#include <chrono>
+
+/** Refresh period for the avalanche statistics computation */
+static constexpr std::chrono::minutes AVALANCHE_STATISTICS_REFRESH_PERIOD{10};
+/** Time constant for the avalanche statistics computation */
+static constexpr std::chrono::minutes AVALANCHE_STATISTICS_TIME_CONSTANT{10};
+/**
+ * Pre-computed decay factor for the avalanche statistics computation.
+ * There is currently no constexpr variant of std::exp, so use a const.
+ */
+static const double AVALANCHE_STATISTICS_DECAY_FACTOR =
+ 1. - std::exp(-1. * AVALANCHE_STATISTICS_REFRESH_PERIOD.count() /
+ AVALANCHE_STATISTICS_TIME_CONSTANT.count());
+
+#endif // BITCOIN_AVALANCHE_STATISTICS_H
diff --git a/src/net.h b/src/net.h
--- a/src/net.h
+++ b/src/net.h
@@ -104,18 +104,6 @@
static const size_t DEFAULT_MAXRECEIVEBUFFER = 5 * 1000;
static const size_t DEFAULT_MAXSENDBUFFER = 1 * 1000;
-/** Refresh period for the avalanche statistics computation */
-static constexpr std::chrono::minutes AVALANCHE_STATISTICS_REFRESH_PERIOD{10};
-/** Time constant for the avalanche statistics computation */
-static constexpr std::chrono::minutes AVALANCHE_STATISTICS_TIME_CONSTANT{10};
-/**
- * Pre-computed decay factor for the avalanche statistics computation.
- * There is currently no constexpr variant of std::exp, so use a const.
- */
-static const double AVALANCHE_STATISTICS_DECAY_FACTOR =
- 1. - std::exp(-1. * AVALANCHE_STATISTICS_REFRESH_PERIOD.count() /
- AVALANCHE_STATISTICS_TIME_CONSTANT.count());
-
struct AddedNodeInfo {
std::string strAddedNode;
CService resolvedAddress;
diff --git a/src/net.cpp b/src/net.cpp
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -12,6 +12,7 @@
#include <addrdb.h>
#include <addrman.h>
#include <avalanche/avalanche.h>
+#include <avalanche/statistics.h>
#include <banman.h>
#include <clientversion.h>
#include <compat.h>
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -11,6 +11,7 @@
#include <avalanche/peermanager.h>
#include <avalanche/processor.h>
#include <avalanche/proof.h>
+#include <avalanche/statistics.h>
#include <avalanche/validation.h>
#include <banman.h>
#include <blockencodings.h>
diff --git a/src/test/net_tests.cpp b/src/test/net_tests.cpp
--- a/src/test/net_tests.cpp
+++ b/src/test/net_tests.cpp
@@ -7,6 +7,7 @@
#include <addrman.h>
#include <avalanche/avalanche.h>
#include <avalanche/processor.h>
+#include <avalanche/statistics.h>
#include <chainparams.h>
#include <clientversion.h>
#include <config.h>
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Feb 6, 16:35 (17 h, 40 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5082708
Default Alt Text
D13003.id37587.diff (2 KB)
Attached To
D13003: [avalanche] Move statistics constants into their own header
Event Timeline
Log In to Comment