Skip to content

Commit

Permalink
Update with responses to Ethen's review
Browse files Browse the repository at this point in the history
  • Loading branch information
teddyknox committed Jun 6, 2024
1 parent 37b0c3d commit 506a4e4
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func EqualSlices[P comparable](s1, s2 []P) bool {
return true
}

func ConvertToBytes(s string) (uint64, error) {
func ParseBytesAmount(s string) (uint64, error) {
s = strings.TrimSpace(s)

// Extract numeric part and unit
Expand Down
2 changes: 1 addition & 1 deletion common/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func TestParseByteAmount(t *testing.T) {

for _, tc := range testCases {
t.Run(fmt.Sprintf("Input: %s", tc.input), func(t *testing.T) {
got, err := common.ConvertToBytes(tc.input)
got, err := common.ParseBytesAmount(tc.input)
if (err != nil) != tc.wantErr {
t.Errorf("wantErr: %v, got error: %v", tc.wantErr, err)
}
Expand Down
5 changes: 4 additions & 1 deletion eigenda/commitment.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ func (c Commitment) Encode() []byte {
}

func StringToCommit(key string) (Commitment, error) {
comm, _ := hexutil.Decode(key)
comm, err := hexutil.Decode(key)
if err != nil {
return nil, err
}
return DecodeCommitment(comm)
}

Expand Down
2 changes: 1 addition & 1 deletion eigenda/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ type Config struct {

func (c *Config) GetMaxBlobLength() (uint64, error) {
if c.maxBlobLengthBytes == 0 {
numBytes, err := common.ConvertToBytes(c.MaxBlobLength)
numBytes, err := common.ParseBytesAmount(c.MaxBlobLength)
if err != nil {
return 0, err
}
Expand Down
4 changes: 1 addition & 3 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,6 @@ func (svr *Server) HandleGet(w http.ResponseWriter, r *http.Request) {
}

func (svr *Server) HandlePut(w http.ResponseWriter, r *http.Request) {
svr.log.Info("PUT", "url", r.URL)

input, err := io.ReadAll(r.Body)
if err != nil {
w.WriteHeader(http.StatusBadRequest)
Expand All @@ -200,7 +198,7 @@ func (svr *Server) HandlePut(w http.ResponseWriter, r *http.Request) {
}

// write out encoded commitment
svr.WriteResponse(w, comm)
svr.WriteResponse(w, eigenda.Commitment.Encode(comm))
}

func (svr *Server) WriteResponse(w http.ResponseWriter, data []byte) {
Expand Down
2 changes: 1 addition & 1 deletion store/eigenda.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (e EigenDAStore) Get(ctx context.Context, key []byte, domain common.DomainT

switch domain {
case common.BinaryDomain:
return e.client.Codec.DecodeBlob(encodedBlob)
return decodedBlob, nil
case common.PolyDomain:
return encodedBlob, nil
default:
Expand Down

0 comments on commit 506a4e4

Please sign in to comment.