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

les: prevent double validation #16955

Closed
Closed
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
11 changes: 10 additions & 1 deletion les/retrieve.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ type sentReq struct {

reqQueued bool // a request has been queued but not sent
reqSent bool // a request has been sent but not timed out
delivered bool // requested data has passed the validation and cached
reqSrtoCount int // number of requests that reached soft (but not hard) timeout
}

Expand Down Expand Up @@ -363,7 +364,15 @@ func (r *sentReq) deliver(peer distPeer, msg *Msg) error {
if !ok || s.delivered {
return errResp(ErrUnexpectedResponse, "reqID = %v", msg.ReqID)
}
valid := r.validate(peer, msg) == nil
valid := false
if r.delivered {
valid = true
} else {
valid = r.validate(peer, msg) == nil
if valid {
r.delivered = true
}
}
r.sentTo[peer] = sentReqToPeer{true, s.valid}
s.valid <- valid
if !valid {
Expand Down