-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sourcery refactored master branch #1
Conversation
93593a9
to
e33df40
Compare
ip_list = [] | ||
ais = socket.getaddrinfo(hostname,0,0,0,0) | ||
for result in ais: | ||
ip_list.append(result[-1][0]) | ||
# ip_list = list(set(ip_list)) | ||
return ip_list | ||
return [result[-1][0] for result in ais] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function nslookup
refactored with the following changes:
- Move assignment closer to its usage within a block (
move-assign-in-block
) - Convert for loop into list comprehension (
list-comprehension
) - Inline variable that is immediately returned (
inline-immediately-returned-variable
)
This removes the following comments ( why? ):
# ip_list = list(set(ip_list))
fp = open('/tmp/nodes.txt') | ||
for node in fp: | ||
nodes = addnode(nodes, node) | ||
fp.close() | ||
with open('/tmp/nodes.txt') as fp: | ||
for node in fp: | ||
nodes = addnode(nodes, node) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function loadnodes
refactored with the following changes:
- Use
with
when opening file to ensure closure (ensure-file-closed
)
nodes = nodes[0:limit] | ||
nodes = nodes[:limit] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function prepare
refactored with the following changes:
- Replace a[0:x] with a[:x] and a[x:len(a)] with a[x:] (
remove-redundant-slice-index
)
for i in range(0, 4): | ||
for _ in range(0, 4): | ||
# print(tx) | ||
newthread(target = broadcast, args = (nodes, tx, )) | ||
newthread(target = broadcast, args = (nodes, tx, )) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function main
refactored with the following changes:
- Replace unused for index with underscore (
for-index-underscore
)
checksum = hashlib.sha256(hashlib.sha256(payload).digest()).digest()[0:4] | ||
checksum = hashlib.sha256(hashlib.sha256(payload).digest()).digest()[:4] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function makeMessage
refactored with the following changes:
- Replace a[0:x] with a[:x] and a[x:len(a)] with a[x:] (
remove-redundant-slice-index
)
time = payload[0:0:4].encode('hex') | ||
time = payload[:0:4].encode('hex') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function disect_netaddress
refactored with the following changes:
- Replace a[0:x] with a[:x] and a[x:len(a)] with a[x:] (
remove-redundant-slice-index
)
version = payload[0:0 + 4].encode('hex') | ||
version = payload[:0 + 4].encode('hex') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function disect_version
refactored with the following changes:
- Replace a[0:x] with a[:x] and a[x:len(a)] with a[x:] (
remove-redundant-slice-index
)
s = [r[0:4], r[4:4 + 12], r[16:16 + 4], r[20:20 + 4], r[24:]] | ||
s = [r[:4], r[4:4 + 12], r[16:16 + 4], r[20:20 + 4], r[24:]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function disect_msg
refactored with the following changes:
- Replace a[0:x] with a[:x] and a[x:len(a)] with a[x:] (
remove-redundant-slice-index
)
checksum = hashlib.sha256(hashlib.sha256(s).digest()).digest()[0:4] | ||
checksum = hashlib.sha256(hashlib.sha256(s).digest()).digest()[:4] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function base58CheckEncode
refactored with the following changes:
- Replace a[0:x] with a[:x] and a[x:len(a)] with a[x:] (
remove-redundant-slice-index
)
checksum = hashlib.sha256(hashlib.sha256(result).digest()).digest()[0:4] | ||
checksum = hashlib.sha256(hashlib.sha256(result).digest()).digest()[:4] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function base58CheckDecode
refactored with the following changes:
- Replace a[0:x] with a[:x] and a[x:len(a)] with a[x:] (
remove-redundant-slice-index
)
Branch
master
refactored by Sourcery.If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.
See our documentation here.
Run Sourcery locally
Reduce the feedback loop during development by using the Sourcery editor plugin:
Review changes via command line
To manually merge these changes, make sure you're on the
master
branch, then run:Help us improve this pull request!