Skip to content

Commit b627924

Browse files
committed
Merge bitcoin/bitcoin#26681: contrib: Bugfix for checking bad dns seeds without casting in makeseeds.py
3cc989d Fix checking bad dns seeds without casting (Yusuf Sahin HAMZA) Pull request description: - Since seed lines comes with `str` type, comparing `good` column 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 a seed is bad; there is no point of going forward from there. Since this bug-fix eliminates bad seeds over **550k** in the first place, in my case; particular job for parsing all seeds speed is up by **600%** and whole script's speed is up by **%30**. Note that **stats** in the terminal are not going to include bad seeds after this fix, which would be the same if this bug were never there before. ACKs for top commit: achow101: ACK 3cc989d jonatack: ACK 3cc989d Tree-SHA512: 13c82681de4d72de07293f0b7f09721ad8514a2ad99b0584d1c94fa5f2818821df2000944f9514d6a222a5dccc82856d16c8c05aa36d905cfa7d4610c629fd38
2 parents d26a71a + 3cc989d commit b627924

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

contrib/seeds/makeseeds.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,16 @@ def parseline(line: str) -> Union[dict, None]:
4646
""" Parses a line from `seeds_main.txt` into a dictionary of details for that line.
4747
or `None`, if the line could not be parsed.
4848
"""
49+
if line.startswith('#'):
50+
# Ignore line that starts with comment
51+
return None
4952
sline = line.split()
5053
if len(sline) < 11:
5154
# line too short to be valid, skip it.
5255
return None
56+
# Skip bad results.
57+
if int(sline[1]) == 0:
58+
return None
5359
m = PATTERN_IPV4.match(sline[0])
5460
sortkey = None
5561
ip = None
@@ -83,9 +89,6 @@ def parseline(line: str) -> Union[dict, None]:
8389
sortkey = ip
8490
ipstr = m.group(1)
8591
port = int(m.group(6))
86-
# Skip bad results.
87-
if sline[1] == 0:
88-
return None
8992
# Extract uptime %.
9093
uptime30 = float(sline[7][:-1])
9194
# Extract Unix timestamp of last success.

0 commit comments

Comments
 (0)