Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chainparams: added backup dns seed #239

Open
wants to merge 2 commits into
base: 0.1.4-dogebox-pre
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ jobs:
goal: install
- name: x86_64-macos
host: x86_64-apple-darwin15
os: macos-12
os: macos-13
run-tests: true
dep-opts: "SPEED=slow V=1"
config-opts: "--enable-static --disable-shared --enable-test-passwd"
Expand Down
2 changes: 1 addition & 1 deletion src/chainparams.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const dogecoin_chainparams dogecoin_chainparams_main = {
{0x91, 0x56, 0x35, 0x2c, 0x18, 0x18, 0xb3, 0x2e, 0x90, 0xc9, 0xe7, 0x92, 0xef, 0xd6, 0xa1, 0x1a, 0x82, 0xfe, 0x79, 0x56, 0xa6, 0x30, 0xf0, 0x3b, 0xbe, 0xe2, 0x36, 0xce, 0xda, 0xe3, 0x91, 0x1a},
{0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
22556,
{{"seed.multidoge.org"}, {{1}}},
{{"seed.multidoge.org"}, {{"seed2.multidoge.org"}}},
true,
0x0062,
{0x00, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, // pow limit
Expand Down
38 changes: 23 additions & 15 deletions src/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -833,21 +833,29 @@ dogecoin_bool dogecoin_node_group_add_peers_by_ip_or_seed(dogecoin_node_group *g
if (ips == NULL) {
/* === DNS QUERY === */
vector* ips_dns = vector_new(10, free);
const dogecoin_dns_seed seed = group->chainparams->dnsseeds[0];
if (strlen(seed.domain) == 0) {
return false;
}
/* todo: make sure we have enough peers, eventually */
dogecoin_get_peers_from_dns(seed.domain, ips_dns, group->chainparams->default_port, AF_INET);
unsigned int i;
for (i = 0; i < ips_dns->len; i++) {
char* ip = (char*)vector_idx(ips_dns, i);

/* create a node */
dogecoin_node* node = dogecoin_node_new();
if (dogecoin_node_set_ipport(node, ip) > 0) {
/* add the node to the group */
dogecoin_node_group_add_node(group, node);
unsigned int seed_index;
/* dogecoin_chainparams has up to 8 dns seeds */
for (seed_index = 0; seed_index < 8; seed_index++) {
const dogecoin_dns_seed seed = group->chainparams->dnsseeds[seed_index];
if (strlen(seed.domain) == 0) {
continue;
}
/* todo: make sure we have enough peers, eventually */
dogecoin_get_peers_from_dns(seed.domain, ips_dns, group->chainparams->default_port, AF_INET);
unsigned int i;
for (i = 0; i < ips_dns->len; i++) {
char* ip = (char*)vector_idx(ips_dns, i);

/* create a node */
dogecoin_node* node = dogecoin_node_new();
if (dogecoin_node_set_ipport(node, ip) > 0) {
/* add the node to the group */
dogecoin_node_group_add_node(group, node);
}
}
/* exit if we get peers from a seed */
if (ips_dns->len > 0) {
break;
}
}
vector_free(ips_dns, true);
Expand Down
23 changes: 16 additions & 7 deletions test/net_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,13 +198,22 @@ void test_net_basics_plus_download_block()
{

vector *ips = vector_new(10, free);
const dogecoin_dns_seed seed = dogecoin_chainparams_test.dnsseeds[0];

dogecoin_get_peers_from_dns(seed.domain, ips, dogecoin_chainparams_test.default_port, AF_INET);
unsigned int i;
for (i = 0; i < ips->len; i++)
{
debug_print("dns seed ip %d: %s\n", i, (char *)vector_idx(ips, i));
unsigned int seed_index;
/* dogecoin_chainparams has up to 8 dns seeds */
for (seed_index = 0; seed_index < 8; seed_index++) {
const dogecoin_dns_seed seed = dogecoin_chainparams_test.dnsseeds[seed_index];
if (strlen(seed.domain) == 0) {
continue;
}
dogecoin_get_peers_from_dns(seed.domain, ips, dogecoin_chainparams_test.default_port, AF_INET);
unsigned int i;
for (i = 0; i < ips->len; i++) {
debug_print("dns seed ip %d: %s\n", i, (char *)vector_idx(ips, i));
}
/* exit if we get peers from a seed */
if (ips->len > 0) {
break;
}
}
vector_free(ips, true);

Expand Down
Loading