-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Rewrite internal logic of block sync client #2715
Changes from 1 commit
76d40ec
0d77c96
ccaca48
0e4d5cb
3f6c418
97b3747
755772e
fc32410
c0c692f
9f82e98
1ec0ded
7982ab5
6551219
8e044be
ac25502
2c43138
7216363
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -378,14 +378,12 @@ func (client *BlockSync) sendRequestToPeer( | |
_ = stream.SetWriteDeadline(time.Now().Add(WRITE_REQ_DEADLINE)) | ||
if err := cborutil.WriteCborRPC(stream, req); err != nil { | ||
_ = stream.SetWriteDeadline(time.Time{}) | ||
// FIXME: What's the point of setting a blank deadline that won't time out? | ||
// Is this our way of clearing the old one? | ||
client.peerTracker.logFailure(peer, build.Clock.Since(connectionStart)) | ||
// FIXME: Should we also remove peer here? | ||
return nil, err | ||
} | ||
// FIXME: Same, why are we doing this again here? | ||
_ = stream.SetWriteDeadline(time.Time{}) | ||
_ = stream.SetWriteDeadline(time.Time{}) // clear deadline // FIXME: Needs | ||
// its own API (/~https://github.com/libp2p/go-libp2p-core/issues/162). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Clearing Deadline by empty time is the Go's standard, I agree specific API might be nice. |
||
|
||
// Read response. | ||
var res Response | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,10 +71,12 @@ func (server *BlockSyncService) HandleStream(stream inet.Stream) { | |
|
||
_ = stream.SetDeadline(time.Now().Add(WRITE_RES_DEADLINE)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. need to clear the deadline too There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. addressed in 6551219 |
||
if err := cborutil.WriteCborRPC(stream, resp); err != nil { | ||
_ = stream.SetDeadline(time.Time{}) | ||
log.Warnw("failed to write back response for handle stream", | ||
"err", err, "peer", stream.Conn().RemotePeer()) | ||
return | ||
} | ||
_ = stream.SetDeadline(time.Time{}) | ||
} | ||
|
||
// Validate and service the request. We return either a protocol | ||
|
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.
i currently assume the peer tracker won't try the peer again unless they are our only other option