Skip to content

Commit cddc263

Browse files
authored
fix usage of zstd library (#63)
1 parent 0f1ad36 commit cddc263

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

encoding/codecv7_types.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package encoding
22

33
import (
4-
"bytes"
54
"encoding/binary"
65
"encoding/hex"
76
"encoding/json"
@@ -478,17 +477,14 @@ func (c *daChunkV7) Hash() (common.Hash, error) {
478477

479478
// decompressV7Bytes decompresses the given blob bytes into the original payload bytes.
480479
func decompressV7Bytes(compressedBytes []byte) ([]byte, error) {
481-
var res []byte
482-
483480
compressedBytes = append(zstdMagicNumber, compressedBytes...)
484-
r := bytes.NewReader(compressedBytes)
485-
zr, err := zstd.NewReader(r, zstd.WithDecoderConcurrency(1))
481+
zr, err := zstd.NewReader(nil, zstd.WithDecoderConcurrency(1))
486482
if err != nil {
487483
return nil, fmt.Errorf("failed to create zstd reader: %w", err)
488484
}
489485
defer zr.Close()
490486

491-
res, err = zr.DecodeAll(compressedBytes, res)
487+
res, err := zr.DecodeAll(compressedBytes, nil)
492488
if err != nil {
493489
return nil, fmt.Errorf("failed to decompress zstd data: %w", err)
494490
}

0 commit comments

Comments
 (0)