diff --git a/contrib/devtools/copyright_header.py b/contrib/devtools/copyright_header.py index e6efff75fd..0f9d2aaae2 100755 --- a/contrib/devtools/copyright_header.py +++ b/contrib/devtools/copyright_header.py @@ -26,7 +26,7 @@ EXCLUDE = [ 'src/crypto/*', 'src/ctpl_stl.h', 'src/reverse_iterator.h', - 'src/statsd_client.cpp', + 'src/stats/client.cpp', 'src/test/fuzz/FuzzedDataProvider.h', 'src/tinyformat.h', 'src/bench/nanobench.h', diff --git a/src/Makefile.am b/src/Makefile.am index ae6b3863e2..e35efcc506 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -313,7 +313,7 @@ BITCOIN_CORE_H = \ spork.h \ stacktraces.h \ streams.h \ - statsd_client.h \ + stats/client.h \ support/allocators/mt_pooled_secure.h \ support/allocators/pool.h \ support/allocators/pooled_secure.h \ @@ -526,7 +526,7 @@ libbitcoin_server_a_SOURCES = \ script/sigcache.cpp \ shutdown.cpp \ spork.cpp \ - statsd_client.cpp \ + stats/client.cpp \ timedata.cpp \ torcontrol.cpp \ txdb.cpp \ diff --git a/src/init.cpp b/src/init.cpp index 18decacf04..1afff5b6de 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -105,7 +105,7 @@ #include #include -#include +#include #include #include @@ -1539,11 +1539,11 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) // We need to initialize g_stats_client early as currently, g_stats_client is called // regardless of whether transmitting stats are desirable or not and if // g_stats_client isn't present when that attempt is made, the client will crash. - ::g_stats_client = std::make_unique(args.GetArg("-statshost", DEFAULT_STATSD_HOST), - args.GetArg("-statshostname", DEFAULT_STATSD_HOSTNAME), - args.GetArg("-statsport", DEFAULT_STATSD_PORT), - args.GetArg("-statsns", DEFAULT_STATSD_NAMESPACE), - args.GetBoolArg("-statsenabled", DEFAULT_STATSD_ENABLE)); + ::g_stats_client = std::make_unique(args.GetArg("-statshost", DEFAULT_STATSD_HOST), + args.GetArg("-statshostname", DEFAULT_STATSD_HOSTNAME), + args.GetArg("-statsport", DEFAULT_STATSD_PORT), + args.GetArg("-statsns", DEFAULT_STATSD_NAMESPACE), + args.GetBoolArg("-statsenabled", DEFAULT_STATSD_ENABLE)); { diff --git a/src/net.cpp b/src/net.cpp index d7863ab05b..c3a51a103a 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -41,7 +41,7 @@ #include #include -#include +#include #ifdef WIN32 #include diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 1735df8669..bdaf5b660b 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -69,7 +69,7 @@ #include #include -#include +#include /** Maximum number of in-flight objects from a peer */ static constexpr int32_t MAX_PEER_OBJECT_IN_FLIGHT = 100; diff --git a/src/statsd_client.cpp b/src/stats/client.cpp similarity index 98% rename from src/statsd_client.cpp rename to src/stats/client.cpp index d9ef85242b..a2683e6156 100644 --- a/src/statsd_client.cpp +++ b/src/stats/client.cpp @@ -33,7 +33,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **/ -#include +#include #include #include @@ -43,9 +43,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -std::unique_ptr g_stats_client; +std::unique_ptr g_stats_client; -namespace statsd { bool StatsdClient::ShouldSend(float sample_rate) { sample_rate = std::clamp(sample_rate, 0.f, 1.f); @@ -193,4 +192,3 @@ bool StatsdClient::send(const std::string& message) return true; } -} // namespace statsd diff --git a/src/statsd_client.h b/src/stats/client.h similarity index 91% rename from src/statsd_client.h rename to src/stats/client.h index cdda53d2e2..eb8a483998 100644 --- a/src/statsd_client.h +++ b/src/stats/client.h @@ -3,15 +3,15 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#ifndef BITCOIN_STATSD_CLIENT_H -#define BITCOIN_STATSD_CLIENT_H +#ifndef BITCOIN_STATS_CLIENT_H +#define BITCOIN_STATS_CLIENT_H #include #include #include -#include #include +#include static constexpr bool DEFAULT_STATSD_ENABLE{false}; static constexpr uint16_t DEFAULT_STATSD_PORT{8125}; @@ -24,8 +24,8 @@ static constexpr int DEFAULT_STATSD_PERIOD{60}; static constexpr int MIN_STATSD_PERIOD{5}; static constexpr int MAX_STATSD_PERIOD{60 * 60}; -namespace statsd { -class StatsdClient { +class StatsdClient +{ public: explicit StatsdClient(const std::string& host, const std::string& nodename, uint16_t port, const std::string& ns, bool enabled); @@ -66,8 +66,7 @@ private: const std::string m_nodename; const std::string m_ns; }; -} // namespace statsd -extern std::unique_ptr g_stats_client; +extern std::unique_ptr g_stats_client; -#endif // BITCOIN_STATSD_CLIENT_H +#endif // BITCOIN_STATS_CLIENT_H diff --git a/src/test/util/setup_common.cpp b/src/test/util/setup_common.cpp index e3453a9a6e..04bcfe43bb 100644 --- a/src/test/util/setup_common.cpp +++ b/src/test/util/setup_common.cpp @@ -39,7 +39,7 @@ #include #include