Skip to content

Commit 4dfac2c

Browse files
committed
Update seeds tooling to Python 3
All the other tooling scripts require Python 3, it makes sense to do so here too. Also document the dependency on python3-dnspython.
1 parent 33f3b21 commit 4dfac2c

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

contrib/seeds/README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1-
### Seeds ###
1+
# Seeds
22

33
Utility to generate the seeds.txt list that is compiled into the client
44
(see [src/chainparamsseeds.h](/src/chainparamsseeds.h) and other utilities in [contrib/seeds](/contrib/seeds)).
55

66
The seeds compiled into the release are created from sipa's DNS seed data, like this:
77

88
curl -s http://bitcoin.sipa.be/seeds.txt > seeds_main.txt
9-
python makeseeds.py < seeds_main.txt > nodes_main.txt
10-
python generate-seeds.py . > ../../src/chainparamsseeds.h
9+
python3 makeseeds.py < seeds_main.txt > nodes_main.txt
10+
python3 generate-seeds.py . > ../../src/chainparamsseeds.h
1111

12+
## Dependencies
13+
14+
Ubuntu:
15+
16+
sudo apt-get install python3-dnspython

contrib/seeds/generate-seeds.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#!/usr/bin/env python
2-
# Copyright (c) 2014 Wladimir J. van der Laan
1+
#!/usr/bin/env python3
2+
# Copyright (c) 2014-2017 Wladimir J. van der Laan
33
# Distributed under the MIT software license, see the accompanying
44
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
55
'''
@@ -31,7 +31,7 @@
3131
3232
These should be pasted into `src/chainparamsseeds.h`.
3333
'''
34-
from __future__ import print_function, division
34+
3535
from base64 import b32decode
3636
from binascii import a2b_hex
3737
import sys, os

contrib/seeds/makeseeds.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#!/usr/bin/env python
2-
# Copyright (c) 2013-2016 The Bitcoin Core developers
1+
#!/usr/bin/env python3
2+
# Copyright (c) 2013-2017 The Bitcoin Core developers
33
# Distributed under the MIT software license, see the accompanying
44
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
55
#
@@ -14,13 +14,13 @@
1414

1515
# These are hosts that have been observed to be behaving strangely (e.g.
1616
# aggressively connecting to every node).
17-
SUSPICIOUS_HOSTS = set([
17+
SUSPICIOUS_HOSTS = {
1818
"130.211.129.106", "178.63.107.226",
1919
"83.81.130.26", "88.198.17.7", "148.251.238.178", "176.9.46.6",
2020
"54.173.72.127", "54.174.10.182", "54.183.64.54", "54.194.231.211",
2121
"54.66.214.167", "54.66.220.137", "54.67.33.14", "54.77.251.214",
2222
"54.94.195.96", "54.94.200.247"
23-
])
23+
}
2424

2525
import re
2626
import sys
@@ -104,7 +104,7 @@ def filtermultiport(ips):
104104
hist = collections.defaultdict(list)
105105
for ip in ips:
106106
hist[ip['sortkey']].append(ip)
107-
return [value[0] for (key,value) in hist.items() if len(value)==1]
107+
return [value[0] for (key,value) in list(hist.items()) if len(value)==1]
108108

109109
# Based on Greg Maxwell's seed_filter.py
110110
def filterbyasn(ips, max_per_asn, max_total):
@@ -164,9 +164,9 @@ def main():
164164

165165
for ip in ips:
166166
if ip['net'] == 'ipv6':
167-
print '[%s]:%i' % (ip['ip'], ip['port'])
167+
print('[%s]:%i' % (ip['ip'], ip['port']))
168168
else:
169-
print '%s:%i' % (ip['ip'], ip['port'])
169+
print('%s:%i' % (ip['ip'], ip['port']))
170170

171171
if __name__ == '__main__':
172172
main()

0 commit comments

Comments
 (0)