Skip to content

Commit

Permalink
Avoid running into error when receiving assist URL (#189)
Browse files Browse the repository at this point in the history
  • Loading branch information
indyjo committed Sep 15, 2019
1 parent 2221f5d commit 507b8f4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
5 changes: 2 additions & 3 deletions client/assist/assist.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func (t *ticketMan) Dump(w io.Writer) (err error) {
return
}
}
_, err = fmt.Fprintf(w, "\nConnections\ndigraph edges {\n")
_, err = fmt.Fprintf(w, "}\n\nConnections\ndigraph edges {\n")
if err != nil {
return
}
Expand All @@ -195,8 +195,7 @@ func (t *ticketMan) Dump(w io.Writer) (err error) {
return
}
}
_, err = fmt.Fprintf(w, "}\n")
_, err = fmt.Fprintf(w, "\nPast Connections\ndigraph past_edges {\n")
_, err = fmt.Fprintf(w, "}\n\nPast Connections\ndigraph past_edges {\n")
if err != nil {
return
}
Expand Down
10 changes: 6 additions & 4 deletions client/client2client.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,10 @@ func (receiver *endpointReceiver) handleRequest(w http.ResponseWriter, r *http.R
return fmt.Errorf("don't know how to handle message (Content-Type: %v)", r.Header.Get("Content-Type"))
}

if (receiver.workFile == nil && receiver.builder == nil) || receiver.buyerSecret == ZEROHASH {
return fmt.Errorf("incomplete work message (work file: %v, chunk hashes: %v. buyer secret: %v)", receiver.workFile != nil, receiver.builder != nil, receiver.buyerSecret != ZEROHASH)
if todo.mustHandleReceipt || todo.mustWriteWishList || todo.mustHandleWork {
if (receiver.workFile == nil && receiver.builder == nil) || receiver.buyerSecret == ZEROHASH {
return fmt.Errorf("incomplete work message (work file: %v, chunk hashes: %v. buyer secret: %v)", receiver.workFile != nil, receiver.builder != nil, receiver.buyerSecret != ZEROHASH)
}
}

if todo.mustHandleReceipt {
Expand Down Expand Up @@ -314,9 +316,9 @@ func (receiver *endpointReceiver) handleRequest(w http.ResponseWriter, r *http.R
return fmt.Errorf("error sending work result back to buyer: %v", err)
}
return reader.Close()
} else {
panic("Shouldn't get here")
}

return nil
}

// Function sendCreatedAssistiveDownloadURLs communicates tickets back to the buyer by
Expand Down

0 comments on commit 507b8f4

Please sign in to comment.