aboutsummaryrefslogtreecommitdiff
path: root/src/net.h
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2016-05-25 15:38:32 +0200
committerPieter Wuille <pieter.wuille@gmail.com>2016-06-07 16:20:40 +0200
commitc31b24f745a84669f2af729052da7fd7ed2da868 (patch)
treed5f2ad6c4df5dbedbe4f3fc23619960f2035e099 /src/net.h
parent9bf156bb9ee4915fa7e8f84589d65f6598563c97 (diff)
downloadbitcoin-c31b24f745a84669f2af729052da7fd7ed2da868.tar.xz
Use 64-bit SipHash of netgroups in eviction
Diffstat (limited to 'src/net.h')
-rw-r--r--src/net.h22
1 files changed, 3 insertions, 19 deletions
diff --git a/src/net.h b/src/net.h
index 019a3f7ee3..8df3cb421f 100644
--- a/src/net.h
+++ b/src/net.h
@@ -9,8 +9,6 @@
#include "amount.h"
#include "bloom.h"
#include "compat.h"
-#include "crypto/common.h"
-#include "crypto/sha256.h"
#include "limitedmap.h"
#include "netbase.h"
#include "protocol.h"
@@ -337,7 +335,7 @@ public:
int64_t nLastRecv;
int64_t nTimeConnected;
int64_t nTimeOffset;
- CAddress addr;
+ const CAddress addr;
std::string addrName;
CService addrLocal;
int nVersion;
@@ -365,7 +363,7 @@ public:
int nRefCount;
NodeId id;
- std::vector<unsigned char> vchKeyedNetGroup;
+ const uint64_t nKeyedNetGroup;
protected:
// Denial-of-service detection/prevention
@@ -454,22 +452,8 @@ private:
CNode(const CNode&);
void operator=(const CNode&);
- void CalculateKeyedNetGroup() {
- static std::vector<unsigned char> vchSecretKey;
- if (vchSecretKey.empty()) {
- vchSecretKey.resize(32, 0);
- GetRandBytes(vchSecretKey.data(), vchSecretKey.size());
- }
-
- std::vector<unsigned char> vchNetGroup(this->addr.GetGroup());
+ static uint64_t CalculateKeyedNetGroup(const CAddress& ad);
- CSHA256 hash;
- hash.Write(begin_ptr(vchNetGroup), vchNetGroup.size());
- hash.Write(begin_ptr(vchSecretKey), vchSecretKey.size());
-
- vchKeyedNetGroup.resize(32, 0);
- hash.Finalize(begin_ptr(vchKeyedNetGroup));
- }
public:
NodeId GetId() const {