Consolidate nullreader files
This commit is contained in:
parent
88f8c7d166
commit
b2a6d308ba
4
extern/storage-sealing/input.go
vendored
4
extern/storage-sealing/input.go
vendored
@ -5,6 +5,8 @@ import (
|
||||
"sort"
|
||||
"time"
|
||||
|
||||
"github.com/filecoin-project/lotus/extern/storage-sealing/lib/nullreader"
|
||||
|
||||
"github.com/filecoin-project/go-padreader"
|
||||
"github.com/filecoin-project/go-statemachine"
|
||||
"github.com/ipfs/go-cid"
|
||||
@ -220,7 +222,7 @@ func (m *Sealing) handleAddPiece(ctx statemachine.Context, sector SectorInfo) er
|
||||
m.minerSector(sector.SectorType, sector.SectorNumber),
|
||||
pieceSizes,
|
||||
p.Unpadded(),
|
||||
NewNullReader(p.Unpadded()))
|
||||
nullreader.NewNullReader(p.Unpadded()))
|
||||
if err != nil {
|
||||
err = xerrors.Errorf("writing padding piece: %w", err)
|
||||
deal.accepted(sector.SectorNumber, offset, err)
|
||||
|
@ -1,5 +1,23 @@
|
||||
package nullreader
|
||||
|
||||
import (
|
||||
"io"
|
||||
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
)
|
||||
|
||||
type NullReader struct {
|
||||
*io.LimitedReader
|
||||
}
|
||||
|
||||
func NewNullReader(size abi.UnpaddedPieceSize) io.Reader {
|
||||
return &NullReader{(io.LimitReader(&Reader{}, int64(size))).(*io.LimitedReader)}
|
||||
}
|
||||
|
||||
func (m NullReader) NullBytes() int64 {
|
||||
return m.N
|
||||
}
|
||||
|
||||
// TODO: extract this to someplace where it can be shared with lotus
|
||||
type Reader struct{}
|
||||
|
||||
|
20
extern/storage-sealing/nullreader.go
vendored
20
extern/storage-sealing/nullreader.go
vendored
@ -1,20 +0,0 @@
|
||||
package sealing
|
||||
|
||||
import (
|
||||
"io"
|
||||
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
nr "github.com/filecoin-project/lotus/extern/storage-sealing/lib/nullreader"
|
||||
)
|
||||
|
||||
type NullReader struct {
|
||||
*io.LimitedReader
|
||||
}
|
||||
|
||||
func NewNullReader(size abi.UnpaddedPieceSize) io.Reader {
|
||||
return &NullReader{(io.LimitReader(&nr.Reader{}, int64(size))).(*io.LimitedReader)}
|
||||
}
|
||||
|
||||
func (m NullReader) NullBytes() int64 {
|
||||
return m.N
|
||||
}
|
4
extern/storage-sealing/states_sealing.go
vendored
4
extern/storage-sealing/states_sealing.go
vendored
@ -4,6 +4,8 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
|
||||
"github.com/filecoin-project/lotus/extern/storage-sealing/lib/nullreader"
|
||||
|
||||
"github.com/ipfs/go-cid"
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
@ -91,7 +93,7 @@ func (m *Sealing) padSector(ctx context.Context, sectorID storage.SectorRef, exi
|
||||
for i, size := range sizes {
|
||||
expectCid := zerocomm.ZeroPieceCommitment(size)
|
||||
|
||||
ppi, err := m.sealer.AddPiece(ctx, sectorID, existingPieceSizes, size, NewNullReader(size))
|
||||
ppi, err := m.sealer.AddPiece(ctx, sectorID, existingPieceSizes, size, nullreader.NewNullReader(size))
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("add piece: %w", err)
|
||||
}
|
||||
|
@ -15,13 +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"
|
||||
sealing "github.com/filecoin-project/lotus/extern/storage-sealing"
|
||||
)
|
||||
|
||||
var log = logging.Logger("rpcenc")
|
||||
|
@ -9,12 +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"
|
||||
sealing "github.com/filecoin-project/lotus/extern/storage-sealing"
|
||||
)
|
||||
|
||||
type ReaderHandler struct {
|
||||
|
Loading…
Reference in New Issue
Block a user