Skip to content

Commit

Permalink
Changes for Litecoin
Browse files Browse the repository at this point in the history
  • Loading branch information
pooler committed Dec 6, 2013
1 parent 9844652 commit 3c64ed5
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 25 deletions.
12 changes: 6 additions & 6 deletions README
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
bitcoin-seeder
==============
litecoin-seeder
===============

Bitcoin-seeder is a crawler for the Bitcoin network, which exposes a list
Litecoin-seeder is a crawler for the Litecoin network, which exposes a list
of reliable nodes via a built-in DNS server.

Features:
* regularly revisits known nodes to check their availability
* bans nodes after enough failures, or bad behaviour
* accepts nodes down to v0.3.19 to request new IP addresses from,
but only reports good post-v0.3.24 nodes.
* accepts nodes down to v0.5.0 to request new IP addresses from,
but only reports good post-v0.6.9 nodes.
* keeps statistics over (exponential) windows of 2 hours, 8 hours,
1 day and 1 week, to base decisions on.
* very low memory (a few tens of megabytes) and cpu requirements.
* crawlers run in parallel (by default 24 threads simultaneously).
* crawlers run in parallel (by default 96 threads simultaneously).

USAGE
-----
Expand Down
4 changes: 2 additions & 2 deletions bitcoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class CNode {
CAddress me(CService("0.0.0.0"));
BeginMessage("version");
int nBestHeight = GetRequireHeight();
string ver = "/bitcoin-seeder:0.01/";
string ver = "/litecoin-seeder:0.01/";
vSend << PROTOCOL_VERSION << nLocalServices << nTime << you << me << nLocalNonce << ver << nBestHeight;
EndMessage();
}
Expand Down Expand Up @@ -296,7 +296,7 @@ bool TestNode(const CService &cip, int &ban, int &clientV, std::string &clientSV

/*
int main(void) {
CService ip("bitcoin.sipa.be", 8333, true);
CService ip("litecointools.com", 9333, true);
vector<CAddress> vAddr;
vAddr.clear();
int ban = 0;
Expand Down
2 changes: 1 addition & 1 deletion combine.pl
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ sub combine {
}

for my $addr (sort { $res->{$b} <=> $res->{$a} } (keys %{$res})) {
if ($addr =~ /\A(\d+)\.(\d+)\.(\d+)\.(\d+):8333/) {
if ($addr =~ /\A(\d+)\.(\d+)\.(\d+)\.(\d+):9333/) {
my $a = $1*0x1000000 + $2*0x10000 + $3*0x100 + $4;
printf "0x%08x %s %g%%\n",$a,$addr,(1-((1-$res->{$addr}) ** (1/$n)))*100;
}
Expand Down
6 changes: 3 additions & 3 deletions db.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@

#define MIN_RETRY 1000

#define REQUIRE_VERSION 40000
#define REQUIRE_VERSION 70002

static inline int GetRequireHeight(const bool testnet = fTestNet)
{
return testnet ? 0 : 230000;
return testnet ? 0 : 470000;
}

std::string static inline ToString(const CService &ip) {
Expand Down Expand Up @@ -119,7 +119,7 @@ class CAddrInfo {
}
int GetBanTime() const {
if (IsGood()) return 0;
if (clientVersion && clientVersion < 31900) { return 604800; }
if (clientVersion && clientVersion < 50000) { return 604800; }
if (stat1M.reliability - stat1M.weight + 1.0 < 0.15 && stat1M.count > 32) { return 30*86400; }
if (stat1W.reliability - stat1W.weight + 1.0 < 0.10 && stat1W.count > 16) { return 7*86400; }
if (stat1D.reliability - stat1D.weight + 1.0 < 0.05 && stat1D.count > 8) { return 1*86400; }
Expand Down
25 changes: 14 additions & 11 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class CDnsSeedOpts {
CDnsSeedOpts() : nThreads(96), nDnsThreads(4), nPort(53), mbox(NULL), ns(NULL), host(NULL), tor(NULL), fUseTestNet(false), fWipeBan(false), fWipeIgnore(false) {}

void ParseCommandLine(int argc, char **argv) {
static const char *help = "Bitcoin-seeder\n"
static const char *help = "Litecoin-seeder\n"
"Usage: %s -h <host> -n <ns> [-m <mbox>] [-t <threads>] [-p <port>]\n"
"\n"
"Options:\n"
Expand Down Expand Up @@ -61,11 +61,11 @@ class CDnsSeedOpts {
{"testnet", no_argument, &fUseTestNet, 1},
{"wipeban", no_argument, &fWipeBan, 1},
{"wipeignore", no_argument, &fWipeBan, 1},
{"help", no_argument, 0, 'h'},
{"help", no_argument, 0, '?'},
{0, 0, 0, 0}
};
int option_index = 0;
int c = getopt_long(argc, argv, "h:n:m:t:p:d:o:", long_options, &option_index);
int c = getopt_long(argc, argv, "h:n:m:t:p:d:o:?", long_options, &option_index);
if (c == -1) break;
switch (c) {
case 'h': {
Expand Down Expand Up @@ -113,7 +113,10 @@ class CDnsSeedOpts {
}
}
if (host != NULL && ns == NULL) showHelp = true;
if (showHelp) fprintf(stderr, help, argv[0]);
if (showHelp) {
fprintf(stderr, help, argv[0]);
exit(0);
}
}
};

Expand Down Expand Up @@ -339,13 +342,13 @@ extern "C" void* ThreadStats(void*) {
} while(1);
}

static const string mainnet_seeds[] = {"dnsseed.bluematt.me", "bitseed.xf2.org", "dnsseed.bitcoin.dashjr.org", "seed.bitcoin.sipa.be", ""};
static const string testnet_seeds[] = {"testnet-seed.bitcoin.petertodd.org", "static-testnet-seed.bitcoin.petertodd.org", ""};
static const string mainnet_seeds[] = {"dnsseed.litecointools.com", "dnsseed.litecoinpool.org", "dnsseed.ltc.xurious.com", ""};
static const string testnet_seeds[] = {"testnet-seed.litecointools.com", ""};
static const string *seeds = mainnet_seeds;

extern "C" void* ThreadSeeder(void*) {
if (!fTestNet){
db.Add(CService("kjy2eqzk4zwi5zd3.onion", 8333), true);
db.Add(CService("kjy2eqzk4zwi5zd3.onion", 9333), true);
}
do {
for (int i=0; seeds[i] != ""; i++) {
Expand Down Expand Up @@ -374,10 +377,10 @@ int main(int argc, char **argv) {
bool fDNS = true;
if (opts.fUseTestNet) {
printf("Using testnet.\n");
pchMessageStart[0] = 0x0b;
pchMessageStart[1] = 0x11;
pchMessageStart[2] = 0x09;
pchMessageStart[3] = 0x07;
pchMessageStart[0] = 0xfc;
pchMessageStart[1] = 0xc1;
pchMessageStart[2] = 0xb7;
pchMessageStart[3] = 0xdc;
seeds = testnet_seeds;
fTestNet = true;
}
Expand Down
2 changes: 1 addition & 1 deletion protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ static const char* ppszTypeName[] =
"block",
};

unsigned char pchMessageStart[4] = { 0xf9, 0xbe, 0xb4, 0xd9 };
unsigned char pchMessageStart[4] = { 0xfb, 0xc0, 0xb6, 0xdb };

CMessageHeader::CMessageHeader()
{
Expand Down
2 changes: 1 addition & 1 deletion protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
extern bool fTestNet;
static inline unsigned short GetDefaultPort(const bool testnet = fTestNet)
{
return testnet ? 18333 : 8333;
return testnet ? 19333 : 9333;
}

//
Expand Down

0 comments on commit 3c64ed5

Please sign in to comment.