mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-24 18:23:26 -03:00
Merge bitcoin/bitcoin#26681: contrib: Bugfix for checking bad dns seeds without casting in makeseeds.py
3cc989da5c
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: ACK3cc989da5c
jonatack: ACK3cc989da5c
Tree-SHA512: 13c82681de4d72de07293f0b7f09721ad8514a2ad99b0584d1c94fa5f2818821df2000944f9514d6a222a5dccc82856d16c8c05aa36d905cfa7d4610c629fd38
This commit is contained in:
commit
b627924300
1 changed files with 6 additions and 3 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Reference in a new issue