From 30b80788f7ca89cab17324245eaf42b982f775a2 Mon Sep 17 00:00:00 2001 From: Roman Mindalev Date: Fri, 9 Aug 2013 11:25:54 +0400 Subject: [PATCH 1/3] RequireHeight differs for mainnet and testnet --- bitcoin.cpp | 2 +- db.h | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/bitcoin.cpp b/bitcoin.cpp index 720126a..cf1c016 100644 --- a/bitcoin.cpp +++ b/bitcoin.cpp @@ -79,7 +79,7 @@ class CNode { int64 nLocalServices = 0; CAddress me(CService("0.0.0.0")); BeginMessage("version"); - int nBestHeight = REQUIRE_HEIGHT; + int nBestHeight = GetRequireHeight(); string ver = "/bitcoin-seeder:0.01/"; vSend << PROTOCOL_VERSION << nLocalServices << nTime << you << me << nLocalNonce << ver << nBestHeight; EndMessage(); diff --git a/db.h b/db.h index 65b48b1..307dd40 100644 --- a/db.h +++ b/db.h @@ -12,9 +12,13 @@ #define MIN_RETRY 1000 -#define REQUIRE_HEIGHT 230000 #define REQUIRE_VERSION 40000 +static inline int GetRequireHeight(const bool testnet = fTestNet) +{ + return testnet ? 0 : 230000; +} + std::string static inline ToString(const CService &ip) { std::string str = ip.ToString(); while (str.size() < 22) str += ' '; @@ -101,7 +105,7 @@ public: if (!(services & NODE_NETWORK)) return false; if (!ip.IsRoutable()) return false; if (clientVersion && clientVersion < REQUIRE_VERSION) return false; - if (blocks && blocks < REQUIRE_HEIGHT) return false; + if (blocks && blocks < GetRequireHeight()) return false; if (total <= 3 && success * 2 >= total) return true; From a5cb7553a22749b79730b9f833d071729027b619 Mon Sep 17 00:00:00 2001 From: Roman Mindalev Date: Fri, 9 Aug 2013 11:56:17 +0400 Subject: [PATCH 2/3] Correct number of threads in built-in help --- main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.cpp b/main.cpp index efd8845..03d9674 100644 --- a/main.cpp +++ b/main.cpp @@ -40,8 +40,8 @@ public: "-h Hostname of the DNS seed\n" "-n Hostname of the nameserver\n" "-m E-Mail address reported in SOA records\n" - "-t Number of crawlers to run in parallel (default 24)\n" - "-d Number of DNS server threads (default 24)\n" + "-t Number of crawlers to run in parallel (default 96)\n" + "-d Number of DNS server threads (default 4)\n" "-p UDP port to listen on (default 53)\n" "-o Tor proxy IP/Port\n" "--testnet Use testnet\n" From 69a942b4e9cb67266b448304f2cad522007e34bf Mon Sep 17 00:00:00 2001 From: Roman Mindalev Date: Fri, 9 Aug 2013 12:28:52 +0400 Subject: [PATCH 3/3] Crawler thread should know amount of threads for correct sleep --- main.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/main.cpp b/main.cpp index 03d9674..2e88ed4 100644 --- a/main.cpp +++ b/main.cpp @@ -11,8 +11,6 @@ #include "bitcoin.h" #include "db.h" -#define NTHREADS 24 - using namespace std; bool fTestNet = false; @@ -126,6 +124,7 @@ extern "C" { CAddrDb db; extern "C" void* ThreadCrawler(void* data) { + int *nThreads=(int*)data; do { std::vector ips; int wait = 5; @@ -133,7 +132,7 @@ extern "C" void* ThreadCrawler(void* data) { int64 now = time(NULL); if (ips.empty()) { wait *= 1000; - wait += rand() % (500 * NTHREADS); + wait += rand() % (500 * *nThreads); Sleep(wait); continue; } @@ -422,7 +421,7 @@ int main(int argc, char **argv) { pthread_attr_setstacksize(&attr_crawler, 0x20000); for (int i=0; i