Skip to content
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

peer: Remove superfluous dup version check. #1248

Merged

Conversation

davecgh
Copy link
Member

@davecgh davecgh commented Jun 3, 2018

This relies on PR #1247.

This removes an impossible to hit duplicate version check and adds a test to ensure the behavior is correct.

Previously, the check was necessary because the handler was a part of the input handler loop, however, the initial negotiation logic was refactored some time ago to be synchronous and thus it is no longer possible to receive a second version message in the refactored code path.

@davecgh davecgh force-pushed the peer_remove_superfluous_dup_version_check branch 2 times, most recently from 42463e1 to 0837320 Compare June 3, 2018 01:54
@davecgh davecgh added this to the 1.3.0 milestone Jun 4, 2018
}
inConn, outConn := pipe(
&conn{laddr: "10.0.0.1:8333", raddr: "10.0.0.2:8333"},
&conn{laddr: "10.0.0.2:8333", raddr: "10.0.0.1:8333"},
Copy link
Member

Choose a reason for hiding this comment

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

any reason to use the bitcoin ports here?

Copy link
Member Author

@davecgh davecgh Jun 4, 2018

Choose a reason for hiding this comment

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

Nope. It was copy paste from the setup in other tests. I'll update it for the default dcrd port, but it really doesn't matter because these are all mock connections that use pipe writers to communicate and thus aren't really opening the port anyway.

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed.

@davecgh davecgh force-pushed the peer_remove_superfluous_dup_version_check branch from 0837320 to e5cae21 Compare June 4, 2018 15:49
}()
select {
case <-disconnected:
close(disconnected)
Copy link
Member

Choose a reason for hiding this comment

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

Actually, this would panic if the disconnect took more than a second to complete. Would be better to buffer the channel and not close it, or use a select to send if ready.

Copy link
Member Author

@davecgh davecgh Jun 4, 2018

Choose a reason for hiding this comment

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

How so? It will only be closed once it reads from the channel. Otherwise, the test will fatal out and take the blocked goroutine with it.

Copy link
Member Author

@davecgh davecgh Jun 4, 2018

Choose a reason for hiding this comment

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

Nevertheless, I'll go ahead and buffer the channel and remove the close though since it doesn't add any value.

@davecgh davecgh force-pushed the peer_remove_superfluous_dup_version_check branch from e5cae21 to e8c1599 Compare June 4, 2018 16:20
This removes an impossible to hit duplicate version check and adds a
test to ensure the behavior is correct.

Previously, the check was necessary because the handler was a part of
the input handler loop, however, the initial negotiation logic was
refactored some time ago to be synchronous and thus it is no longer
possible to receive a second version message in the refactored code
path.
@davecgh davecgh force-pushed the peer_remove_superfluous_dup_version_check branch from e8c1599 to da74b4b Compare June 4, 2018 16:22
@davecgh davecgh merged commit da74b4b into decred:master Jun 4, 2018
@davecgh davecgh deleted the peer_remove_superfluous_dup_version_check branch June 4, 2018 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants