diff --git a/include/bitcoin/protocol/config/authority.hpp b/include/bitcoin/protocol/config/authority.hpp
index d22d706..2daa1bb 100644
--- a/include/bitcoin/protocol/config/authority.hpp
+++ b/include/bitcoin/protocol/config/authority.hpp
@@ -16,7 +16,6 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
-
#ifndef LIBBITCOIN_PROTOCOL_CONFIG_AUTHORITY_HPP
#define LIBBITCOIN_PROTOCOL_CONFIG_AUTHORITY_HPP
diff --git a/include/bitcoin/protocol/config/sodium.hpp b/include/bitcoin/protocol/config/sodium.hpp
index 30517fc..6eb1842 100644
--- a/include/bitcoin/protocol/config/sodium.hpp
+++ b/include/bitcoin/protocol/config/sodium.hpp
@@ -37,8 +37,6 @@ class BCP_API sodium
/// A list of base85 values.
/// This must provide operator<< for ostream in order to be used as a
/// boost::program_options default_value.
- typedef std::vector list;
-
sodium() NOEXCEPT;
sodium(const std::string& base85) THROWS;
sodium(const system::hash_digest& value) NOEXCEPT;
@@ -61,6 +59,8 @@ class BCP_API sodium
system::hash_digest value_;
};
+typedef std::vector sodiums;
+
} // namespace protocol
} // namespace libbitcoin
diff --git a/include/bitcoin/protocol/define.hpp b/include/bitcoin/protocol/define.hpp
index 7016c46..edd4973 100644
--- a/include/bitcoin/protocol/define.hpp
+++ b/include/bitcoin/protocol/define.hpp
@@ -37,17 +37,6 @@
#define BCP_INTERNAL BC_HELPER_DLL_LOCAL
#endif
-// Log name.
-////#define LOG_PROTOCOL "protocol"
-////#define LOG_PROTOCOL_HTTP "http"
-////
-////// TODO: generalize logging.
-////#define LOG_INFO(name) std::cout << name << " : "
-////#define LOG_DEBUG(name) std::cout << name << " : "
-////#define LOG_VERBOSE(name) std::cout << name << " : "
-////#define LOG_ERROR(name) std::cerr << name << " : "
-////#define LOG_WARNING(name) std::cerr << name << " : "
-
#endif
// context ->
diff --git a/include/bitcoin/protocol/network.hpp b/include/bitcoin/protocol/network.hpp
index 5cae347..9c8e89a 100644
--- a/include/bitcoin/protocol/network.hpp
+++ b/include/bitcoin/protocol/network.hpp
@@ -24,22 +24,29 @@
// config::authority and config::endpoint are also cloned from network.
#include
+#include
#include
#ifdef HAVE_MSC
#include
+ // #define THREAD_PRIORITY_IDLE -15
+ // #define THREAD_PRIORITY_LOWEST -2
+ // #define THREAD_PRIORITY_BELOW_NORMAL -1
+ // #define THREAD_PRIORITY_NORMAL 0
+ // #define THREAD_PRIORITY_ABOVE_NORMAL 1
+ // #define THREAD_PRIORITY_HIGHEST 2
+ // #define THREAD_PRIORITY_TIME_CRITICAL 15
+ // #define THREAD_PRIORITY_ERROR_RETURN (MAXLONG)
#else
#include
#include
#include
#include
- #ifndef PRIO_MAX
- #define PRIO_MAX 20
- #endif
- #define THREAD_PRIORITY_ABOVE_NORMAL (-2)
- #define THREAD_PRIORITY_NORMAL 0
- #define THREAD_PRIORITY_BELOW_NORMAL 2
- #define THREAD_PRIORITY_LOWEST PRIO_MAX
+ #define THREAD_PRIORITY_HIGHEST -20
+ #define THREAD_PRIORITY_ABOVE_NORMAL -2
+ #define THREAD_PRIORITY_NORMAL 0
+ #define THREAD_PRIORITY_BELOW_NORMAL 2
+ #define THREAD_PRIORITY_LOWEST 20
#endif
namespace libbitcoin {
@@ -62,6 +69,7 @@ class enable_shared_from_base
enum class thread_priority
{
+ highest,
high,
normal,
low,
@@ -79,26 +87,43 @@ inline int get_priority(thread_priority priority) NOEXCEPT
return THREAD_PRIORITY_BELOW_NORMAL;
case thread_priority::high:
return THREAD_PRIORITY_ABOVE_NORMAL;
+ case thread_priority::highest:
+ return THREAD_PRIORITY_HIGHEST;
default:
case thread_priority::normal:
return THREAD_PRIORITY_NORMAL;
}
}
-// Set the thread priority (or process if thread priority is not available).
+// Set the thread priority.
+// TODO: handle error conditions.
+// TODO: handle potential lack of PRIO_THREAD
+// TODO: use proper non-win32 priority levels.
+// TODO: Linux: pthread_setschedprio()
+// TOOD: macOS: somethign else.
inline void set_priority(thread_priority priority) NOEXCEPT
{
const auto prioritization = get_priority(priority);
- BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT)
#if defined(HAVE_MSC)
+ // learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/
+ // nf-processthreadsapi-getthreadpriority
SetThreadPriority(GetCurrentThread(), prioritization);
+
#elif defined(PRIO_THREAD)
+ // lore.kernel.org/lkml/1220278355.3866.21.camel@localhost.localdomain/
setpriority(PRIO_THREAD, pthread_self(), prioritization);
+
#else
+ // BUGBUG: This will set all threads in the process.
+ // man7.org/linux/man-pages/man3/pthread_self.3.html
setpriority(PRIO_PROCESS, getpid(), prioritization);
#endif
- BC_POP_WARNING()
+}
+
+inline size_t cores() NOEXCEPT
+{
+ return std::max(std::thread::hardware_concurrency(), 1_u32);
}
} // namespace protocol
diff --git a/install-cmake.sh b/install-cmake.sh
index bf2ca50..497a4c6 100755
--- a/install-cmake.sh
+++ b/install-cmake.sh
@@ -906,7 +906,7 @@ build_from_tarball_boost()
"$BOOST_CXXFLAGS" \
"$BOOST_LINKFLAGS" \
"link=$BOOST_LINK" \
- "warnings=off" \
+ "warnings=off" \
"boost.locale.iconv=$BOOST_ICU_ICONV" \
"boost.locale.posix=$BOOST_ICU_POSIX" \
"-sNO_BZIP2=1" \
diff --git a/install-cmakepresets.sh b/install-cmakepresets.sh
index 29d51cd..9bdd8d7 100755
--- a/install-cmakepresets.sh
+++ b/install-cmakepresets.sh
@@ -945,7 +945,7 @@ build_from_tarball_boost()
"$BOOST_CXXFLAGS" \
"$BOOST_LINKFLAGS" \
"link=$BOOST_LINK" \
- "warnings=off" \
+ "warnings=off" \
"boost.locale.iconv=$BOOST_ICU_ICONV" \
"boost.locale.posix=$BOOST_ICU_POSIX" \
"-sNO_BZIP2=1" \
diff --git a/install.sh b/install.sh
index 734ee70..4fec2ae 100755
--- a/install.sh
+++ b/install.sh
@@ -781,7 +781,7 @@ build_from_tarball_boost()
"$BOOST_CXXFLAGS" \
"$BOOST_LINKFLAGS" \
"link=$BOOST_LINK" \
- "warnings=off" \
+ "warnings=off" \
"boost.locale.iconv=$BOOST_ICU_ICONV" \
"boost.locale.posix=$BOOST_ICU_POSIX" \
"-sNO_BZIP2=1" \
diff --git a/src/zmq/authenticator.cpp b/src/zmq/authenticator.cpp
index 65410c2..0b0dd65 100644
--- a/src/zmq/authenticator.cpp
+++ b/src/zmq/authenticator.cpp
@@ -51,7 +51,7 @@ authenticator::~authenticator() NOEXCEPT
stop();
}
-authenticator::operator context& () NOEXCEPT
+authenticator::operator context&() NOEXCEPT
{
return context_;
}
diff --git a/src/zmq/worker.cpp b/src/zmq/worker.cpp
index 07a382d..c6a6236 100644
--- a/src/zmq/worker.cpp
+++ b/src/zmq/worker.cpp
@@ -33,8 +33,6 @@ namespace zmq {
using namespace bc::system;
-#define NAME "worker"
-
// Derive from this abstract worker to implement concrete worker.
worker::worker(thread_priority priority) NOEXCEPT
: priority_(priority),