X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Faddrman.cpp;h=f24e7e78202c89d64b4a6354ce6ebd65e2832215;hb=HEAD;hp=ed17c39f1c74fd83341fa4d1a882723957330536;hpb=576f3bde12e58e1b1a3c429955bcd7b92860169a;p=novacoin.git diff --git a/src/addrman.cpp b/src/addrman.cpp index ed17c39..6c3f394 100644 --- a/src/addrman.cpp +++ b/src/addrman.cpp @@ -4,6 +4,8 @@ #include "addrman.h" #include "hash.h" +#include "random.h" +#include "streams.h" using namespace std; @@ -398,7 +400,7 @@ CAddress CAddrMan::Select_(int nUnkBias) { // use a tried node double fChanceFactor = 1.0; - while(1) + for ( ; ; ) { int nKBucket = GetRandInt(vvTried.size()); std::vector &vTried = vvTried[nKBucket]; @@ -413,7 +415,7 @@ CAddress CAddrMan::Select_(int nUnkBias) } else { // use a new node double fChanceFactor = 1.0; - while(1) + for ( ; ; ) { int nUBucket = GetRandInt(vvNew.size()); std::set &vNew = vvNew[nUBucket]; @@ -537,3 +539,13 @@ void CAddrMan::Connected_(const CService &addr, int64_t nTime) if (nTime - info.nTime > nUpdateInterval) info.nTime = nTime; } + +CAddrMan::CAddrMan() : vRandom(0), vvTried(ADDRMAN_TRIED_BUCKET_COUNT, std::vector(0)), vvNew(ADDRMAN_NEW_BUCKET_COUNT, std::set()) +{ + nKey.resize(32); + GetRandBytes(&nKey[0], 32); + + nIdCount = 0; + nTried = 0; + nNew = 0; +}