Browse Source

Merge pull request #11 from r000n/master

Small fixes
pull/1/head
Pieter Wuille 11 years ago
parent
commit
4c1171d9a3
  1. 2
      bitcoin.cpp
  2. 8
      db.h
  3. 11
      main.cpp

2
bitcoin.cpp

@ -79,7 +79,7 @@ class CNode {
int64 nLocalServices = 0; int64 nLocalServices = 0;
CAddress me(CService("0.0.0.0")); CAddress me(CService("0.0.0.0"));
BeginMessage("version"); BeginMessage("version");
int nBestHeight = REQUIRE_HEIGHT; int nBestHeight = GetRequireHeight();
string ver = "/bitcoin-seeder:0.01/"; string ver = "/bitcoin-seeder:0.01/";
vSend << PROTOCOL_VERSION << nLocalServices << nTime << you << me << nLocalNonce << ver << nBestHeight; vSend << PROTOCOL_VERSION << nLocalServices << nTime << you << me << nLocalNonce << ver << nBestHeight;
EndMessage(); EndMessage();

8
db.h

@ -12,9 +12,13 @@
#define MIN_RETRY 1000 #define MIN_RETRY 1000
#define REQUIRE_HEIGHT 230000
#define REQUIRE_VERSION 40000 #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 static inline ToString(const CService &ip) {
std::string str = ip.ToString(); std::string str = ip.ToString();
while (str.size() < 22) str += ' '; while (str.size() < 22) str += ' ';
@ -101,7 +105,7 @@ public:
if (!(services & NODE_NETWORK)) return false; if (!(services & NODE_NETWORK)) return false;
if (!ip.IsRoutable()) return false; if (!ip.IsRoutable()) return false;
if (clientVersion && clientVersion < REQUIRE_VERSION) 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; if (total <= 3 && success * 2 >= total) return true;

11
main.cpp

@ -11,8 +11,6 @@
#include "bitcoin.h" #include "bitcoin.h"
#include "db.h" #include "db.h"
#define NTHREADS 24
using namespace std; using namespace std;
bool fTestNet = false; bool fTestNet = false;
@ -40,8 +38,8 @@ public:
"-h <host> Hostname of the DNS seed\n" "-h <host> Hostname of the DNS seed\n"
"-n <ns> Hostname of the nameserver\n" "-n <ns> Hostname of the nameserver\n"
"-m <mbox> E-Mail address reported in SOA records\n" "-m <mbox> E-Mail address reported in SOA records\n"
"-t <threads> Number of crawlers to run in parallel (default 24)\n" "-t <threads> Number of crawlers to run in parallel (default 96)\n"
"-d <threads> Number of DNS server threads (default 24)\n" "-d <threads> Number of DNS server threads (default 4)\n"
"-p <port> UDP port to listen on (default 53)\n" "-p <port> UDP port to listen on (default 53)\n"
"-o <ip:port> Tor proxy IP/Port\n" "-o <ip:port> Tor proxy IP/Port\n"
"--testnet Use testnet\n" "--testnet Use testnet\n"
@ -126,6 +124,7 @@ extern "C" {
CAddrDb db; CAddrDb db;
extern "C" void* ThreadCrawler(void* data) { extern "C" void* ThreadCrawler(void* data) {
int *nThreads=(int*)data;
do { do {
std::vector<CServiceResult> ips; std::vector<CServiceResult> ips;
int wait = 5; int wait = 5;
@ -133,7 +132,7 @@ extern "C" void* ThreadCrawler(void* data) {
int64 now = time(NULL); int64 now = time(NULL);
if (ips.empty()) { if (ips.empty()) {
wait *= 1000; wait *= 1000;
wait += rand() % (500 * NTHREADS); wait += rand() % (500 * *nThreads);
Sleep(wait); Sleep(wait);
continue; continue;
} }
@ -422,7 +421,7 @@ int main(int argc, char **argv) {
pthread_attr_setstacksize(&attr_crawler, 0x20000); pthread_attr_setstacksize(&attr_crawler, 0x20000);
for (int i=0; i<opts.nThreads; i++) { for (int i=0; i<opts.nThreads; i++) {
pthread_t thread; pthread_t thread;
pthread_create(&thread, &attr_crawler, ThreadCrawler, NULL); pthread_create(&thread, &attr_crawler, ThreadCrawler, &opts.nThreads);
} }
pthread_attr_destroy(&attr_crawler); pthread_attr_destroy(&attr_crawler);
printf("done\n"); printf("done\n");

Loading…
Cancel
Save