Skip to content

Conversation

@sanjaykdragon
Copy link
Contributor

referring to: #17020
good first issue: reading SUSPICIOUS_HOSTS from a file.
I haven't changed the base hosts that were included in the original source, just made it readable from a file.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Slightly shorter using strip() and RAII:

with open("suspicious_hosts.txt") as f:
    SUSPICIOUS_HOSTS = {s.strip() for s in f if s.strip()}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Slightly shorter using strip() and RAII:

with open("suspicious_hosts.txt") as f:
    SUSPICIOUS_HOSTS = {s.strip() for s in f if s.strip()}

Didn't know that strip() would work in this case, just changed it

@practicalswift
Copy link
Contributor

practicalswift commented Dec 29, 2019

Please squash and use a more descriptive commit message + PR title :)

Suggestion: contrib: makeseeds: Read suspicious hosts from a file instead of hardcoding

Also you might want to sort the entries in contrib/seeds/suspicious_hosts.txt to make it clear where in the file to add new entries without causing unnecessary merge conflicts.

BTW, welcome as a contributor! :)

@sanjaykdragon
Copy link
Contributor Author

sanjaykdragon commented Dec 29, 2019

Please squash and use a more descriptive commit message + PR title :)

Suggestion: contrib: makeseeds: Read suspicious hosts from a file instead of hardcoding

Also you might want to sort the entries in contrib/seeds/suspicious_hosts.txt to make it clear where in the file to add new entries without causing unnecessary merge conflicts.

BTW, welcome as a contributor! :)

what do you mean sort entries?
And thanks for the welcome, also just squashed the commits.

@sanjaykdragon sanjaykdragon changed the title script: makeseeds.py improvements contrib/scripts: makeseeds: Read suspicious hosts from a file instead of hardcoding Dec 29, 2019
@fanquake fanquake changed the title contrib/scripts: makeseeds: Read suspicious hosts from a file instead of hardcoding scripts: Read suspicious hosts from a file instead of hardcoding Dec 29, 2019
@practicalswift
Copy link
Contributor

what do you mean sort entries?

Sort the lines in the file :)

sort -u -o contrib/seeds/suspicious_hosts.txt contrib/seeds/suspicious_hosts.txt in your shell, or M-x sort-lines in an editor built on the shoulders of matching parentheses :)

@sanjaykdragon
Copy link
Contributor Author

what do you mean sort entries?

Sort the lines in the file :)

sort -u -o contrib/seeds/suspicious_hosts.txt contrib/seeds/suspicious_hosts.txt in your shell, or M-x sort-lines in an editor built on the shoulders of matching parentheses :)

Seems pretty pointless, but I did it anyways.

@practicalswift
Copy link
Contributor

Sort the lines in the file :)
sort -u -o contrib/seeds/suspicious_hosts.txt contrib/seeds/suspicious_hosts.txt in your shell, or M-x sort-lines in an editor built on the shoulders of matching parentheses :)

Seems pretty pointless, but I did it anyways.

The reason to sort entries is that it makes it clear where in the file to add new entries in the future.

In unsorted files people typically append new entries to the end of the file which is likely to cause merge conflicts if two different PR:s add entries to the same file.

Thus sorting the file will help avoid future merge conflicts :)

Makes sense? :)

@sanjaykdragon
Copy link
Contributor Author

Sort the lines in the file :)
sort -u -o contrib/seeds/suspicious_hosts.txt contrib/seeds/suspicious_hosts.txt in your shell, or M-x sort-lines in an editor built on the shoulders of matching parentheses :)

Seems pretty pointless, but I did it anyways.

The reason to sort entries is that it makes it clear where in the file to add new entries in the future.

In unsorted files people typically append new entries to the end of the file which is likely to cause merge conflicts if two different PR:s add entries to the same file.

Thus sorting the file will help avoid future merge conflicts :)

Makes sense? :)

Oh, I thought you mean that people were just idiots and didn't know how to append to a file. Thanks for the explanation!

@paymog
Copy link

paymog commented Jan 4, 2020

ack b9eb76ece28b4e86b94ecad32f6b5fb35310a7ef

@laanwj
Copy link
Member

laanwj commented Jan 4, 2020

Thank you!
I'm not even sure the suspicious hosts file should be in the repository, but that's another concern.
ACK b9eb76ece28b4e86b94ecad32f6b5fb35310a7ef

@laanwj laanwj mentioned this pull request Jan 4, 2020
11 tasks
@laanwj
Copy link
Member

laanwj commented Jan 4, 2020

A few linter issues:

Python's open(...) seems to be used to open text files without explicitly

specifying encoding="utf8":

contrib/seeds/makeseeds.py:with open("suspicious_hosts.txt") as f:

^---- failure generated from test/lint/lint-python-utf8-encoding.sh

contrib/seeds/makeseeds.py:23:1: W191 indentation contains tabs

contrib/seeds/makeseeds.py:30:1: E101 indentation contains mixed spaces and tabs

@sanjaykdragon
Copy link
Contributor Author

A few linter issues:

Python's open(...) seems to be used to open text files without explicitly

specifying encoding="utf8":

contrib/seeds/makeseeds.py:with open("suspicious_hosts.txt") as f:

^---- failure generated from test/lint/lint-python-utf8-encoding.sh

contrib/seeds/makeseeds.py:23:1: W191 indentation contains tabs

contrib/seeds/makeseeds.py:30:1: E101 indentation contains mixed spaces and tabs

fixed, I think

@fanquake
Copy link
Member

fanquake commented Jan 6, 2020

@sanjaykdragon Can you squash your commits.

@practicalswift
Copy link
Contributor

ACK e1c582c -- diff looks correct

@sanjaykdragon
Copy link
Contributor Author

@laanwj you mind merging this?

"54.66.214.167", "54.66.220.137", "54.67.33.14", "54.77.251.214",
"54.94.195.96", "54.94.200.247"
}
with open("suspicious_hosts.txt", mode="r", encoding="utf-8") as f:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty sure this tries to read the file in the pwd, not in this folder. Is the script required to run in this folder, so that pwd==this folder already holds for other reasons?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty sure this tries to read the file in the pwd, not in this folder. Is the script required to run in this folder, so that pwd==this folder already holds for other reasons?

Not sure where this script is supposed to be run from.

Copy link
Member

@laanwj laanwj Jan 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's supposed to be run from the folder it is in, at least according to the instructions in the README (that I always follow): https://github.com/bitcoin/bitcoin/blob/master/contrib/seeds/README.md

(would make sense to make this path configurable, though, for example through a command line option)

laanwj added a commit that referenced this pull request Jan 20, 2020
…ardcoding

e1c582c contrib: makeseeds: Read suspicious hosts from a file instead of hardcoding (Sanjay K)

Pull request description:

  referring to: #17020
  good first issue: reading SUSPICIOUS_HOSTS from a file.
  I haven't changed the base hosts that were included in the original source, just made it readable from a file.

ACKs for top commit:
  practicalswift:
    ACK e1c582c -- diff looks correct

Tree-SHA512: 18684abc1c02cf52d63f6f6ecd98df01a9574a7c470524c37e152296504e2e3ffbabd6f3208214b62031512aeb809a6d37446af82c9f480ff14ce4c42c98e7c2
@laanwj laanwj merged commit e1c582c into bitcoin:master Jan 20, 2020
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Jan 24, 2020
…ad of hardcoding

e1c582c contrib: makeseeds: Read suspicious hosts from a file instead of hardcoding (Sanjay K)

Pull request description:

  referring to: bitcoin#17020
  good first issue: reading SUSPICIOUS_HOSTS from a file.
  I haven't changed the base hosts that were included in the original source, just made it readable from a file.

ACKs for top commit:
  practicalswift:
    ACK e1c582c -- diff looks correct

Tree-SHA512: 18684abc1c02cf52d63f6f6ecd98df01a9574a7c470524c37e152296504e2e3ffbabd6f3208214b62031512aeb809a6d37446af82c9f480ff14ce4c42c98e7c2
sidhujag pushed a commit to syscoin-core/syscoin that referenced this pull request Nov 10, 2020
…ad of hardcoding

e1c582c contrib: makeseeds: Read suspicious hosts from a file instead of hardcoding (Sanjay K)

Pull request description:

  referring to: bitcoin#17020
  good first issue: reading SUSPICIOUS_HOSTS from a file.
  I haven't changed the base hosts that were included in the original source, just made it readable from a file.

ACKs for top commit:
  practicalswift:
    ACK e1c582c -- diff looks correct

Tree-SHA512: 18684abc1c02cf52d63f6f6ecd98df01a9574a7c470524c37e152296504e2e3ffbabd6f3208214b62031512aeb809a6d37446af82c9f480ff14ce4c42c98e7c2
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Feb 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants