Skip to content

Commit

Permalink
fix: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
acha-bill committed Feb 27, 2024
1 parent 05cbfae commit 4229233
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pkg/api/chunk.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,15 @@ func (s *Service) chunkUploadHandler(w http.ResponseWriter, r *http.Request) {
return
}

chunk, err := cac.NewWithDataSpan(data)
hash, err := cac.DoHash(data[swarm.SpanSize:], data[:swarm.SpanSize])
if err != nil {
logger.Debug("chunk upload: create chunk failed", "error", err)
logger.Error(nil, "chunk upload: create chunk error")
jsonhttp.InternalServerError(ow, "create chunk error")
logger.Debug("chunk upload: hash data", "error", err)
logger.Error(nil, "chunk upload: hash data error")
jsonhttp.InternalServerError(ow, "hash data error")
return
}

chunk := swarm.NewChunk(swarm.NewAddress(hash), data)
err = putter.Put(r.Context(), chunk)
if err != nil {
logger.Debug("chunk upload: write chunk failed", "chunk_address", chunk.Address(), "error", err)
Expand Down

0 comments on commit 4229233

Please sign in to comment.