Changeset View
Changeset View
Standalone View
Standalone View
contrib/seeds/generate-seeds.py
Show First 20 Lines • Show All 92 Lines • ▼ Show 20 Lines | else: | ||||
port = int(port) | port = int(port) | ||||
host = name_to_ipv6(host) | host = name_to_ipv6(host) | ||||
return (host, port) | return (host, port) | ||||
def process_nodes(g, f, structname, defaultport): | def process_nodes(g, f, structname, defaultport): | ||||
g.write('static std::vector<SeedSpec6> {} = {{\n'.format(structname)) | g.write('std::vector<SeedSpec6> {} = {{\n'.format(structname)) | ||||
first = True | first = True | ||||
for line in f: | for line in f: | ||||
comment = line.find('#') | comment = line.find('#') | ||||
if comment != -1: | if comment != -1: | ||||
line = line[0:comment] | line = line[0:comment] | ||||
line = line.strip() | line = line.strip() | ||||
if not line: | if not line: | ||||
continue | continue | ||||
Show All 11 Lines | def main(): | ||||
if len(sys.argv) < 2: | if len(sys.argv) < 2: | ||||
print( | print( | ||||
'Usage: {} <path_to_nodes_txt>'.format( | 'Usage: {} <path_to_nodes_txt>'.format( | ||||
sys.argv[0]), | sys.argv[0]), | ||||
file=sys.stderr) | file=sys.stderr) | ||||
sys.exit(1) | sys.exit(1) | ||||
g = sys.stdout | g = sys.stdout | ||||
indir = sys.argv[1] | indir = sys.argv[1] | ||||
g.write('#ifndef BITCOIN_CHAINPARAMSSEEDS_H\n') | g.write('#include <chainparams.h>\n') | ||||
g.write('#define BITCOIN_CHAINPARAMSSEEDS_H\n') | |||||
g.write('/**\n') | g.write('/**\n') | ||||
g.write(' * List of fixed seed nodes for the bitcoin network\n') | g.write(' * List of fixed seed nodes for the bitcoin network\n') | ||||
g.write(' * @{} by contrib/seeds/generate-seeds.py\n'.format('generated')) | g.write(' * @{} by contrib/seeds/generate-seeds.py\n'.format('generated')) | ||||
g.write(' *\n') | g.write(' *\n') | ||||
g.write(' * Each line contains a 16-byte IPv6 address and a port.\n') | g.write(' * Each line contains a 16-byte IPv6 address and a port.\n') | ||||
g.write( | g.write( | ||||
' * IPv4 as well as onion addresses are wrapped inside an IPv6 address accordingly.\n') | ' * IPv4 as well as onion addresses are wrapped inside an IPv6 address accordingly.\n') | ||||
g.write(' */\n') | g.write(' */\n') | ||||
with open(os.path.join(indir, 'nodes_main.txt'), 'r', encoding="utf8") as f: | with open(os.path.join(indir, 'nodes_main.txt'), 'r', encoding="utf8") as f: | ||||
process_nodes(g, f, 'pnSeed6_main', 8333) | process_nodes(g, f, 'pnSeed6_main', 8333) | ||||
g.write('\n') | g.write('\n') | ||||
with open(os.path.join(indir, 'nodes_test.txt'), 'r', encoding="utf8") as f: | with open(os.path.join(indir, 'nodes_test.txt'), 'r', encoding="utf8") as f: | ||||
process_nodes(g, f, 'pnSeed6_test', 18333) | process_nodes(g, f, 'pnSeed6_test', 18333) | ||||
g.write('#endif // BITCOIN_CHAINPARAMSSEEDS_H\n') | |||||
if __name__ == '__main__': | if __name__ == '__main__': | ||||
main() | main() |