Fixed std::random_device usage
This commit is contained in:
@@ -85,9 +85,10 @@ ConsoleCommands::ConsoleCommands(p2pool* pool)
|
||||
}
|
||||
|
||||
std::random_device rd;
|
||||
std::mt19937_64 rng(rd());
|
||||
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
if (start_listening(false, "127.0.0.1", 49152 + (rd() % 16384))) {
|
||||
if (start_listening(false, "127.0.0.1", 49152 + (rng() % 16384))) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -453,9 +453,10 @@ MergeMiningClientTari::TariServer::TariServer(const std::string& socks5Proxy)
|
||||
bool MergeMiningClientTari::TariServer::start()
|
||||
{
|
||||
std::random_device rd;
|
||||
std::mt19937_64 rng(rd());
|
||||
|
||||
for (size_t i = 0; i < 10; ++i) {
|
||||
if (start_listening(false, "127.0.0.1", 49152 + (rd() % 16384))) {
|
||||
if (start_listening(false, "127.0.0.1", 49152 + (rng() % 16384))) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,9 +42,10 @@ ZMQReader::ZMQReader(const std::string& address, uint32_t zmq_port, const std::s
|
||||
addr_buf[0] = '\0';
|
||||
|
||||
std::random_device rd;
|
||||
std::mt19937_64 rng(rd());
|
||||
|
||||
for (uint32_t i = 0; i < 100; ++i) {
|
||||
const uint32_t port = 49152 + (rd() % 16384);
|
||||
const uint32_t port = 49152 + (rng() % 16384);
|
||||
|
||||
try {
|
||||
log::Stream s(addr_buf);
|
||||
@@ -215,6 +216,7 @@ bool ZMQReader::connect(const std::string& address, bool keep_monitor)
|
||||
if (!id) {
|
||||
std::random_device rd;
|
||||
id = (static_cast<uint64_t>(rd()) << 32) | static_cast<uint32_t>(rd());
|
||||
id >>= 1; // to avoid MAX_UINT64 case
|
||||
}
|
||||
|
||||
char buf[64];
|
||||
|
||||
Reference in New Issue
Block a user