From 03b87a3e64305ba651e22a730e35271dea8fea64 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Tue, 2 Apr 2024 14:29:24 +0100 Subject: Drop Windows Socket dependency for `randomenv.cpp` This change drops a dependency on the ws2_32 library for our libbitcoinkernel, which may not be desirable. --- src/randomenv.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/randomenv.cpp') diff --git a/src/randomenv.cpp b/src/randomenv.cpp index da81a61651..123b5cc06c 100644 --- a/src/randomenv.cpp +++ b/src/randomenv.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -357,10 +358,19 @@ void RandAddStaticEnv(CSHA512& hasher) hasher << &hasher << &RandAddStaticEnv << &malloc << &errno << &environ; // Hostname +#ifdef WIN32 + constexpr DWORD max_size = MAX_COMPUTERNAME_LENGTH + 1; + char hname[max_size]; + DWORD size = max_size; + if (GetComputerNameA(hname, &size) != 0) { + hasher.Write(UCharCast(hname), size); + } +#else char hname[256]; if (gethostname(hname, 256) == 0) { hasher.Write((const unsigned char*)hname, strnlen(hname, 256)); } +#endif #if HAVE_DECL_GETIFADDRS && HAVE_DECL_FREEIFADDRS // Network interfaces -- cgit v1.2.3