aboutsummaryrefslogtreecommitdiff
path: root/src/addrman.cpp
diff options
context:
space:
mode:
authorThomas Holenstein <[email protected]>2013-12-21 16:50:49 +0100
committerThomas Holenstein <[email protected]>2013-12-25 11:07:21 +0100
commite85e19be06c59529bfda100729e8ef3148349952 (patch)
treec1be2bb3178a5e9a9eadd61cded2067094f83271 /src/addrman.cpp
parentMerge pull request #3453 (diff)
downloaddiscoin-e85e19be06c59529bfda100729e8ef3148349952.tar.xz
discoin-e85e19be06c59529bfda100729e8ef3148349952.zip
Changed Get64(.) to GetLow64()
The function Get64(.) has a bug in case the width is not divisible by 64. Since it is only ever used as Get64(0) this simply changes it to this special case. Additionally, an assert is added, and a cast to prevent a compiler error.
Diffstat (limited to 'src/addrman.cpp')
-rw-r--r--src/addrman.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/addrman.cpp b/src/addrman.cpp
index 815da07c9..46b4a9493 100644
--- a/src/addrman.cpp
+++ b/src/addrman.cpp
@@ -14,12 +14,12 @@ int CAddrInfo::GetTriedBucket(const std::vector<unsigned char> &nKey) const
CDataStream ss1(SER_GETHASH, 0);
std::vector<unsigned char> vchKey = GetKey();
ss1 << nKey << vchKey;
- uint64_t hash1 = Hash(ss1.begin(), ss1.end()).Get64();
+ 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);
- uint64_t hash2 = Hash(ss2.begin(), ss2.end()).Get64();
+ uint64_t hash2 = Hash(ss2.begin(), ss2.end()).GetLow64();
return hash2 % ADDRMAN_TRIED_BUCKET_COUNT;
}
@@ -29,11 +29,11 @@ int CAddrInfo::GetNewBucket(const std::vector<unsigned char> &nKey, const CNetAd
std::vector<unsigned char> vchGroupKey = GetGroup();
std::vector<unsigned char> vchSourceGroupKey = src.GetGroup();
ss1 << nKey << vchGroupKey << vchSourceGroupKey;
- uint64_t hash1 = Hash(ss1.begin(), ss1.end()).Get64();
+ uint64_t hash1 = Hash(ss1.begin(), ss1.end()).GetLow64();
CDataStream ss2(SER_GETHASH, 0);
ss2 << nKey << vchSourceGroupKey << (hash1 % ADDRMAN_NEW_BUCKETS_PER_SOURCE_GROUP);
- uint64_t hash2 = Hash(ss2.begin(), ss2.end()).Get64();
+ uint64_t hash2 = Hash(ss2.begin(), ss2.end()).GetLow64();
return hash2 % ADDRMAN_NEW_BUCKET_COUNT;
}