Skip to content

Commit

Permalink
Update lib/rpcenc/reader.go
Browse files Browse the repository at this point in the history
Co-authored-by: Łukasz Magiera <magik6k@users.noreply.github.com>
  • Loading branch information
geoff-vball and magik6k committed May 2, 2022
1 parent 5030fd2 commit ebf5eb6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions lib/rpcenc/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ import (
"sync"
"time"

sealing "github.com/filecoin-project/lotus/extern/storage-sealing/lib/nullreader"

"github.com/google/uuid"
logging "github.com/ipfs/go-log/v2"
"golang.org/x/xerrors"

"github.com/filecoin-project/go-jsonrpc"
"github.com/filecoin-project/go-state-types/abi"

"github.com/filecoin-project/lotus/extern/storage-sealing/lib/nullreader"
)

var log = logging.Logger("rpcenc")
Expand Down Expand Up @@ -102,7 +102,7 @@ func ReaderParamEncoder(addr string) jsonrpc.Option {
return jsonrpc.WithParamEncoder(new(io.Reader), func(value reflect.Value) (reflect.Value, error) {
r := value.Interface().(io.Reader)

if r, ok := r.(*sealing.NullReader); ok {
if r, ok := r.(*nullreader.NullReader); ok {
return reflect.ValueOf(ReaderStream{Type: Null, Info: fmt.Sprint(r.N)}), nil
}

Expand Down Expand Up @@ -419,7 +419,7 @@ func ReaderParamDecoder() (http.HandlerFunc, jsonrpc.ServerOption) {
return reflect.Value{}, xerrors.Errorf("parsing null byte count: %w", err)
}

return reflect.ValueOf(sealing.NewNullReader(abi.UnpaddedPieceSize(n))), nil
return reflect.ValueOf(nullreader.NewNullReader(abi.UnpaddedPieceSize(n))), nil
}

u, err := uuid.Parse(rs.Info)
Expand Down
8 changes: 4 additions & 4 deletions lib/rpcenc/reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import (
"strings"
"testing"

sealing "github.com/filecoin-project/lotus/extern/storage-sealing/lib/nullreader"

"github.com/gorilla/mux"
"github.com/stretchr/testify/require"
"golang.org/x/xerrors"

"github.com/filecoin-project/go-jsonrpc"

"github.com/filecoin-project/lotus/extern/storage-sealing/lib/nullreader"
)

type ReaderHandler struct {
Expand Down Expand Up @@ -58,7 +58,7 @@ func (h *ReaderHandler) ReadAll(ctx context.Context, r io.Reader) ([]byte, error
}

func (h *ReaderHandler) ReadNullLen(ctx context.Context, r io.Reader) (int64, error) {
return r.(*sealing.NullReader).N, nil
return r.(*nullreader.NullReader).N, nil
}

func (h *ReaderHandler) ReadUrl(ctx context.Context, u string) (string, error) {
Expand Down Expand Up @@ -119,7 +119,7 @@ func TestNullReaderProxy(t *testing.T) {

defer closer()

n, err := client.ReadNullLen(context.TODO(), sealing.NewNullReader(1016))
n, err := client.ReadNullLen(context.TODO(), nullreader.NewNullReader(1016))
require.NoError(t, err)
require.Equal(t, int64(1016), n)
}
Expand Down

0 comments on commit ebf5eb6

Please sign in to comment.