Update CMakeLists.txt - play with openssl
[novacoin.git] / src / addrman.cpp
index ed17c39..6c3f394 100644 (file)
@@ -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<int> &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<int> &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<int>(0)), vvNew(ADDRMAN_NEW_BUCKET_COUNT, std::set<int>())
+{
+    nKey.resize(32);
+    GetRandBytes(&nKey[0], 32);
+
+    nIdCount = 0;
+    nTried = 0;
+    nNew = 0;
+}