diff --git a/pkg/api/bzz.go b/pkg/api/bzz.go index a07f3f0f54f..14a236c183f 100644 --- a/pkg/api/bzz.go +++ b/pkg/api/bzz.go @@ -426,7 +426,7 @@ FETCH: jsonhttp.NotFound(w, "no update found") return } - wc, err := feeds.GetWrappedChunk(ctx, s.storer.ChunkStore(), ch) + wc, err := feeds.GetWrappedChunk(ctx, s.storer.Download(cache), ch) if err != nil { logger.Debug("bzz download: mapStructure feed update failed", "error", err) logger.Error(nil, "bzz download: mapStructure feed update failed") diff --git a/pkg/api/feed.go b/pkg/api/feed.go index 7c92f3fd855..e2ab2f0affa 100644 --- a/pkg/api/feed.go +++ b/pkg/api/feed.go @@ -102,7 +102,7 @@ func (s *Service) feedGetHandler(w http.ResponseWriter, r *http.Request) { return } - wc, err := feeds.GetWrappedChunk(r.Context(), s.storer.ChunkStore(), ch) + wc, err := feeds.GetWrappedChunk(r.Context(), s.storer.Download(false), ch) if err != nil { logger.Error(nil, "wrapped chunk cannot be retrieved") jsonhttp.NotFound(w, "wrapped chunk cannot be retrieved") diff --git a/pkg/feeds/getter.go b/pkg/feeds/getter.go index 9fcb2ccae77..5f902703ef8 100644 --- a/pkg/feeds/getter.go +++ b/pkg/feeds/getter.go @@ -6,7 +6,6 @@ package feeds import ( "context" - "encoding/binary" "errors" "fmt" "time" @@ -60,7 +59,7 @@ func GetWrappedChunk(ctx context.Context, getter storage.Getter, ch swarm.Chunk) // possible values right now: // unencrypted ref: span+timestamp+ref => 8+8+32=48 // encrypted ref: span+timestamp+ref+decryptKey => 8+8+64=80 - _, ref, err := LegacyPayload(wc) + ref, err := legacyPayload(wc) if err != nil { if errors.Is(err, errNotLegacyPayload) { return wc, nil @@ -84,14 +83,12 @@ func FromChunk(ch swarm.Chunk) (swarm.Chunk, error) { return s.WrappedChunk(), nil } -// LegacyPayload returns back the referenced chunk and datetime from the legacy feed payload -func LegacyPayload(wrappedChunk swarm.Chunk) (uint64, swarm.Address, error) { +// legacyPayload returns back the referenced chunk and datetime from the legacy feed payload +func legacyPayload(wrappedChunk swarm.Chunk) (swarm.Address, error) { cacData := wrappedChunk.Data() if !(len(cacData) == 16+swarm.HashSize || len(cacData) == 16+swarm.HashSize*2) { - return 0, swarm.ZeroAddress, errNotLegacyPayload + return swarm.ZeroAddress, errNotLegacyPayload } - address := swarm.NewAddress(cacData[16:]) - at := binary.BigEndian.Uint64(cacData[8:16]) - return at, address, nil + return swarm.NewAddress(cacData[16:]), nil }