mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-19 23:03:45 +01:00
Merge #8173: Use SipHash for node eviction (cont'd)
eebc232test: Add more test vectors for siphash (Wladimir J. van der Laan)8884830Use C++11 thread-safe static initializers (Pieter Wuille)c31b24fUse 64-bit SipHash of netgroups in eviction (Pieter Wuille)9bf156bSupport SipHash with arbitrary byte writes (Pieter Wuille)053930fAvoid recalculating vchKeyedNetGroup in eviction logic. (Patrick Strateman)
This commit is contained in:
@@ -4783,11 +4783,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||
LOCK(cs_vNodes);
|
||||
// Use deterministic randomness to send to the same nodes for 24 hours
|
||||
// at a time so the addrKnowns of the chosen nodes prevent repeats
|
||||
static uint64_t salt0 = 0, salt1 = 0;
|
||||
while (salt0 == 0 && salt1 == 0) {
|
||||
GetRandBytes((unsigned char*)&salt0, sizeof(salt0));
|
||||
GetRandBytes((unsigned char*)&salt1, sizeof(salt1));
|
||||
}
|
||||
static const uint64_t salt0 = GetRand(std::numeric_limits<uint64_t>::max());
|
||||
static const uint64_t salt1 = GetRand(std::numeric_limits<uint64_t>::max());
|
||||
uint64_t hashAddr = addr.GetHash();
|
||||
multimap<uint64_t, CNode*> mapMix;
|
||||
const CSipHasher hasher = CSipHasher(salt0, salt1).Write(hashAddr << 32).Write((GetTime() + hashAddr) / (24*60*60));
|
||||
|
||||
Reference in New Issue
Block a user