Skip to content

Remove check for impossible condition in x/sync #1348

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

Merged
merged 4 commits into from
Apr 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions x/sync/network_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,6 @@ func (c *networkClient) RequestAny(
// If the limit on active requests is reached, this function blocks until
// a slot becomes available.
func (c *networkClient) Request(ctx context.Context, nodeID ids.NodeID, request []byte) ([]byte, error) {
// TODO danlaine: is it possible for this condition to occur?
if nodeID == ids.EmptyNodeID {
return nil, fmt.Errorf("cannot send request to empty nodeID, nodeID=%s, requestLen=%d", nodeID, len(request))
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems like a useful check to leave on the exported method, I think.
Even if all current uses are correct it might catch errors in future development.

Not very strongly opinionated, happy to defer to @dboehm-avalabs

}

// Take a slot from total [activeRequests] and block until a slot becomes available.
if err := c.activeRequests.Acquire(ctx, 1); err != nil {
return nil, ErrAcquiringSemaphore
Expand Down