Skip to content

Commit

Permalink
return err instead of breaking when buf read fails
Browse files Browse the repository at this point in the history
  • Loading branch information
ian-shim committed Mar 18, 2024
1 parent a002ac2 commit fdd2e62
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions node/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"context"
"encoding/binary"
"errors"
"io"
"time"

"github.com/Layr-Labs/eigenda/api/grpc/node"
Expand Down Expand Up @@ -361,15 +362,24 @@ func decodeChunks(data []byte) ([][]byte, error) {

for {
var length uint64
if err := binary.Read(buf, binary.LittleEndian, &length); err != nil {
err := binary.Read(buf, binary.LittleEndian, &length)
if errors.Is(err, io.EOF) {
break
}
if err != nil {
return nil, err
}

chunk := make([]byte, length)
if _, err := buf.Read(chunk); err != nil {
_, err = buf.Read(chunk)
if errors.Is(err, io.EOF) {
break
}
chunks = append(chunks, chunk)
if err != nil {
return nil, err
}

chunks = append(chunks, chunk)
if buf.Len() < 8 {
break
}
Expand Down

0 comments on commit fdd2e62

Please sign in to comment.