Skip to content

Commit

Permalink
fix: asd
Browse files Browse the repository at this point in the history
  • Loading branch information
istae committed Dec 11, 2024
1 parent f9e2d0a commit 6a0e497
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions pkg/feeds/getter.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package feeds

import (
"context"
"encoding/binary"
"errors"
"fmt"
"time"
Expand Down Expand Up @@ -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
Expand All @@ -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
}

0 comments on commit 6a0e497

Please sign in to comment.