MCPcopy Create free account
hub / github.com/WaykiChain/WaykiChain / GetNewBucket

Method GetNewBucket

src/p2p/addrman.cpp:26–38  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24}
25
26int CAddrInfo::GetNewBucket(const vector<unsigned char> &nKey, const CNetAddr& src) const
27{
28 CDataStream ss1(SER_GETHASH, 0);
29 vector<unsigned char> vchGroupKey = GetGroup();
30 vector<unsigned char> vchSourceGroupKey = src.GetGroup();
31 ss1 << nKey << vchGroupKey << vchSourceGroupKey;
32 uint64_t hash1 = Hash(ss1.begin(), ss1.end()).GetCheapHash();
33
34 CDataStream ss2(SER_GETHASH, 0);
35 ss2 << nKey << vchSourceGroupKey << (hash1 % ADDRMAN_NEW_BUCKETS_PER_SOURCE_GROUP);
36 uint64_t hash2 = Hash(ss2.begin(), ss2.end()).GetCheapHash();
37 return hash2 % ADDRMAN_NEW_BUCKET_COUNT;
38}
39
40bool CAddrInfo::IsTerrible(int64_t nNow) const
41{

Callers 2

MakeTriedMethod · 0.45
Add_Method · 0.45

Calls 5

GetGroupMethod · 0.80
GetCheapHashMethod · 0.80
HashFunction · 0.50
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected