-
Notifications
You must be signed in to change notification settings - Fork 38.7k
qa: Only allow disconnecting all NodeConns #11641
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
Conversation
| p2p_conns = [] | ||
|
|
||
| for i in range(3): | ||
| for _ in range(3): |
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.
Interested in the use of the underscore as the variable name here, did some reading and from what I've read use of the underscore only works as something other than a variable name when used in an interactive python shell? Other than that people seem to believe it's a bad naming convention.
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.
_ as a variable name in python is a convention to indicate that the result won't be used.
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.
Thanks for the explanation, makes sense.
| """Close all p2p connections to the node.""" | ||
| for _ in range(len(self.p2ps)): | ||
| index = 0 | ||
| # Connection could have already been closed by other end. |
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.
Is the order of deletion relevant? If not, something like this is both easier to read and likely more efficient:
for x in self.p2ps:
if x.connection is not None:
x.connection.disconnect_node()
self.p2ps = []
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.
No, the order is not relevant. Will switch to your suggestion. (I tried to minimize the --ignore-all-space diff)
fa3408a to
fa3a437
Compare
fa3a437 to
faaa7db
Compare
|
utACK faaa7db |
faaa7db qa: Only allow disconnecting all NodeConns (MarcoFalke) Pull request description: Disconnecting the connection with `index=0` makes no sense when there are more than one connections, as the list "rotates around" and populates index 0 after `del`. Just disconnect all NodeConns in any case. Tree-SHA512: e5cf540823fccb31634b5a11501f54222be89862e80ccafc28bc06726480f8d2153b8c1b6f859fa6a6d087876251d48a6c6035bccdaaf16831e300bc17ff613d
faaa7db qa: Only allow disconnecting all NodeConns (MarcoFalke) Pull request description: Disconnecting the connection with `index=0` makes no sense when there are more than one connections, as the list "rotates around" and populates index 0 after `del`. Just disconnect all NodeConns in any case. Tree-SHA512: e5cf540823fccb31634b5a11501f54222be89862e80ccafc28bc06726480f8d2153b8c1b6f859fa6a6d087876251d48a6c6035bccdaaf16831e300bc17ff613d
Disconnecting the connection with
index=0makes no sense when there are more than one connections, as the list "rotates around" and populates index 0 afterdel.Just disconnect all NodeConns in any case.