mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-03 01:33:20 +02:00
Seed RNG with precision timestamps on receipt of net messages.
This commit is contained in:
10
src/net.cpp
10
src/net.cpp
@@ -16,6 +16,7 @@
|
||||
#include <crypto/sha256.h>
|
||||
#include <netbase.h>
|
||||
#include <net_permissions.h>
|
||||
#include <random.h>
|
||||
#include <scheduler.h>
|
||||
#include <ui_interface.h>
|
||||
#include <util/strencodings.h>
|
||||
@@ -445,6 +446,9 @@ CNode* CConnman::ConnectNode(CAddress addrConnect, const char *pszDest, bool fCo
|
||||
CNode* pnode = new CNode(id, nLocalServices, GetBestHeight(), hSocket, addrConnect, CalculateKeyedNetGroup(addrConnect), nonce, addr_bind, pszDest ? pszDest : "", false, block_relay_only);
|
||||
pnode->AddRef();
|
||||
|
||||
// We're making a new connection, harvest entropy from the time (and our peer count)
|
||||
RandAddEvent((uint32_t)id);
|
||||
|
||||
return pnode;
|
||||
}
|
||||
|
||||
@@ -693,6 +697,9 @@ CNetMessage V1TransportDeserializer::GetMessage(const CMessageHeader::MessageSta
|
||||
msg.m_message_size = hdr.nMessageSize;
|
||||
msg.m_raw_message_size = hdr.nMessageSize + CMessageHeader::HEADER_SIZE;
|
||||
|
||||
// We just received a message off the wire, harvest entropy from the time (and the message checksum)
|
||||
RandAddEvent(ReadLE32(hash.begin()));
|
||||
|
||||
msg.m_valid_checksum = (memcmp(hash.begin(), hdr.pchChecksum, CMessageHeader::CHECKSUM_SIZE) == 0);
|
||||
if (!msg.m_valid_checksum) {
|
||||
LogPrint(BCLog::NET, "CHECKSUM ERROR (%s, %u bytes), expected %s was %s\n",
|
||||
@@ -1017,6 +1024,9 @@ void CConnman::AcceptConnection(const ListenSocket& hListenSocket) {
|
||||
LOCK(cs_vNodes);
|
||||
vNodes.push_back(pnode);
|
||||
}
|
||||
|
||||
// We received a new connection, harvest entropy from the time (and our peer count)
|
||||
RandAddEvent((uint32_t)id);
|
||||
}
|
||||
|
||||
void CConnman::DisconnectNodes()
|
||||
|
||||
Reference in New Issue
Block a user