aboutsummaryrefslogtreecommitdiff
path: root/src/addrman.cpp
diff options
context:
space:
mode:
authorPieter Wuille <[email protected]>2015-03-08 06:30:05 -0700
committerRoss Nicoll <[email protected]>2015-06-27 14:15:32 +0000
commitbd36a593d6eecd050ba1bb52b28e188798474f51 (patch)
tree1fc86691960e92b369f610e6667d64d0a55a556d /src/addrman.cpp
parentReduce fingerprinting through timestamps in 'addr' messages. (diff)
downloaddiscoin-bd36a593d6eecd050ba1bb52b28e188798474f51.tar.xz
discoin-bd36a593d6eecd050ba1bb52b28e188798474f51.zip
Switch addrman key from vector to uint256
Conflicts: src/addrman.cpp Rebased-From: b23add5521e4207085d41a0266617e94435fc22e Github-Pull: #5941
Diffstat (limited to 'src/addrman.cpp')
-rw-r--r--src/addrman.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/addrman.cpp b/src/addrman.cpp
index 79545e13c..359ff75e5 100644
--- a/src/addrman.cpp
+++ b/src/addrman.cpp
@@ -9,30 +9,30 @@
using namespace std;
-int CAddrInfo::GetTriedBucket(const std::vector<unsigned char> &nKey) const
+int CAddrInfo::GetTriedBucket(const uint256& nKey) const
{
CDataStream ss1(SER_GETHASH, 0);
std::vector<unsigned char> vchKey = GetKey();
- ss1 << nKey << vchKey;
+ ss1 << ((unsigned char)32) << nKey << vchKey;
uint64_t hash1 = Hash(ss1.begin(), ss1.end()).GetLow64();
CDataStream ss2(SER_GETHASH, 0);
std::vector<unsigned char> vchGroupKey = GetGroup();
- ss2 << nKey << vchGroupKey << (hash1 % ADDRMAN_TRIED_BUCKETS_PER_GROUP);
+ ss2 << ((unsigned char)32) << nKey << vchGroupKey << (hash1 % ADDRMAN_TRIED_BUCKETS_PER_GROUP);
uint64_t hash2 = Hash(ss2.begin(), ss2.end()).GetLow64();
return hash2 % ADDRMAN_TRIED_BUCKET_COUNT;
}
-int CAddrInfo::GetNewBucket(const std::vector<unsigned char> &nKey, const CNetAddr& src) const
+int CAddrInfo::GetNewBucket(const uint256& nKey, const CNetAddr& src) const
{
CDataStream ss1(SER_GETHASH, 0);
std::vector<unsigned char> vchGroupKey = GetGroup();
std::vector<unsigned char> vchSourceGroupKey = src.GetGroup();
- ss1 << nKey << vchGroupKey << vchSourceGroupKey;
+ ss1 << ((unsigned char)32) << nKey << vchGroupKey << vchSourceGroupKey;
uint64_t hash1 = Hash(ss1.begin(), ss1.end()).GetLow64();
CDataStream ss2(SER_GETHASH, 0);
- ss2 << nKey << vchSourceGroupKey << (hash1 % ADDRMAN_NEW_BUCKETS_PER_SOURCE_GROUP);
+ ss2 << ((unsigned char)32) << nKey << vchSourceGroupKey << (hash1 % ADDRMAN_NEW_BUCKETS_PER_SOURCE_GROUP);
uint64_t hash2 = Hash(ss2.begin(), ss2.end()).GetLow64();
return hash2 % ADDRMAN_NEW_BUCKET_COUNT;
}
@@ -486,6 +486,8 @@ int CAddrMan::Check_()
if (setTried.size()) return -13;
if (mapNew.size()) return -15;
+ if (nKey.IsNull())
+ return -16;
return 0;
}