aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfanquake <fanquake@gmail.com>2023-04-20 09:52:17 +0100
committerfanquake <fanquake@gmail.com>2023-04-20 10:04:47 +0100
commitb6279243002a4bca2c87bd366dc908747aa5b513 (patch)
treed3e2ab042aeb6911c2edf319103984abc07ea627
parentd26a71a94ac4ae1b1a091f4412d390afba69b2f8 (diff)
parent3cc989da5c750e740705131bed05bbf93bfdf169 (diff)
downloadbitcoin-b6279243002a4bca2c87bd366dc908747aa5b513.tar.xz
Merge bitcoin/bitcoin#26681: contrib: Bugfix for checking bad dns seeds without casting in `makeseeds.py`
3cc989da5c750e740705131bed05bbf93bfdf169 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 3cc989da5c750e740705131bed05bbf93bfdf169 jonatack: ACK 3cc989da5c750e740705131bed05bbf93bfdf169 Tree-SHA512: 13c82681de4d72de07293f0b7f09721ad8514a2ad99b0584d1c94fa5f2818821df2000944f9514d6a222a5dccc82856d16c8c05aa36d905cfa7d4610c629fd38
-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 23d38ee48d..bec589c44f 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.