aboutsummaryrefslogtreecommitdiff
path: root/contrib/seeds
diff options
context:
space:
mode:
authorYusuf Sahin HAMZA <yusufsahinhamza@gmail.com>2022-12-10 19:30:28 +0300
committerYusuf Sahin HAMZA <yusufsahinhamza@gmail.com>2022-12-10 19:30:28 +0300
commit3cc989da5c750e740705131bed05bbf93bfdf169 (patch)
treeff370bfa871b317ae86c30285569dad9eb6c17bf /contrib/seeds
parent1ea02791f3d81c7716d9ea455971203f74d7a107 (diff)
downloadbitcoin-3cc989da5c750e740705131bed05bbf93bfdf169.tar.xz
Fix checking bad dns seeds without casting
Since seed lines comes with 'str' type, comparing it directly with 0 ('int' type) in the if statement was not working at all. This is fixed by casting 'int' type to the values in the 'good' column of seeds text file. Lines that starts with comment in the seeds text file are now ignored. If statement for checking bad seeds are moved to the top of the 'parseline' function as if seed is bad, there is no point of going forward from there.
Diffstat (limited to 'contrib/seeds')
-rwxr-xr-xcontrib/seeds/makeseeds.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/contrib/seeds/makeseeds.py b/contrib/seeds/makeseeds.py
index eda58c370f..09b6ceb785 100755
--- a/contrib/seeds/makeseeds.py
+++ b/contrib/seeds/makeseeds.py
@@ -46,10 +46,16 @@ def parseline(line: str) -> Union[dict, None]:
""" Parses a line from `seeds_main.txt` into a dictionary of details for that line.
or `None`, if the line could not be parsed.
"""
+ if line.startswith('#'):
+ # Ignore line that starts with comment
+ return None
sline = line.split()
if len(sline) < 11:
# line too short to be valid, skip it.
return None
+ # Skip bad results.
+ if int(sline[1]) == 0:
+ return None
m = PATTERN_IPV4.match(sline[0])
sortkey = None
ip = None
@@ -83,9 +89,6 @@ def parseline(line: str) -> Union[dict, None]:
sortkey = ip
ipstr = m.group(1)
port = int(m.group(6))
- # Skip bad results.
- if sline[1] == 0:
- return None
# Extract uptime %.
uptime30 = float(sline[7][:-1])
# Extract Unix timestamp of last success.