Update lib/rpcenc/reader.go

Co-authored-by: Łukasz Magiera <magik6k@users.noreply.github.com>
This commit is contained in:
Geoff Stuart 2022-04-19 14:14:15 -03:00
parent 5030fd2589
commit ebf5eb6e28
2 changed files with 8 additions and 8 deletions

View File

@ -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")
@ -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
}
@ -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)

View File

@ -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 {
@ -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) {
@ -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)
}