"end", end,
"len", end-begin,
)
- go func() {
- // Detach cost association from webseed update requests routine.
- pprof.SetGoroutineLabels(context.Background())
- ws.runRequest(&wsReq)
- }()
+ go ws.sliceProcessor(&wsReq)
}
func (me *webseedPeer) getRequestKey(wr *webseedRequest) webseedUniqueRequestKey {
return slog.LevelWarn
}
-func (ws *webseedPeer) runRequest(webseedRequest *webseedRequest) {
+// Reads chunks from the responses for the webseed slice.
+func (ws *webseedPeer) sliceProcessor(webseedRequest *webseedRequest) {
+ // Detach cost association from webseed update requests routine.
+ pprof.SetGoroutineLabels(context.Background())
locker := ws.locker
err := ws.readChunks(webseedRequest)
if webseed.PrintDebug && webseedRequest.next < webseedRequest.end {
Body: body,
bodyPipe: body,
}
- go func() {
- pprof.SetGoroutineLabels(context.Background())
- err := ws.readRequestPartResponses(ctx, w, requestParts)
- panicif.Err(w.CloseWithError(err))
- }()
+ go ws.requestPartResponsesReader(ctx, w, requestParts)
return req
}
+// Concatenates request part responses and sends them over the pipe.
+func (ws *Client) requestPartResponsesReader(ctx context.Context, w *io.PipeWriter, requestParts []requestPart) {
+ pprof.SetGoroutineLabels(context.Background())
+ err := ws.readRequestPartResponses(ctx, w, requestParts)
+ panicif.Err(w.CloseWithError(err))
+}
+
type ErrBadResponse struct {
Msg string
Response *http.Response