refactor: make GetRand a template, remove GetRandInt

This commit is contained in:
pasta
2022-01-31 19:32:59 +07:00
parent 505ba39665
commit ab1ea29ba1
12 changed files with 34 additions and 31 deletions

View File

@@ -4470,10 +4470,10 @@ void PeerManagerImpl::MaybeSendPing(CNode& node_to, Peer& peer, std::chrono::mic
}
if (pingSend) {
uint64_t nonce = 0;
while (nonce == 0) {
GetRandBytes({(unsigned char*)&nonce, sizeof(nonce)});
}
uint64_t nonce;
do {
nonce = GetRand<uint64_t>();
} while (nonce == 0);
peer.m_ping_queued = false;
peer.m_ping_start = now;
if (node_to.GetCommonVersion() > BIP0031_VERSION) {