More post-refactor fixes

This commit is contained in:
Łukasz Magiera 2019-11-07 19:43:15 +01:00
parent 58c21b4a5e
commit f40eb8a521
4 changed files with 19 additions and 14 deletions

View File

@ -12,6 +12,7 @@ import (
logging "github.com/ipfs/go-log" logging "github.com/ipfs/go-log"
"github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/address" "github.com/filecoin-project/lotus/chain/address"
"github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/node/impl" "github.com/filecoin-project/lotus/node/impl"
@ -20,6 +21,8 @@ import (
func TestDealFlow(t *testing.T, b APIBuilder) { func TestDealFlow(t *testing.T, b APIBuilder) {
os.Setenv("BELLMAN_NO_GPU", "1") os.Setenv("BELLMAN_NO_GPU", "1")
build.SectorSizes = []uint64{1024}
logging.SetAllLoggers(logging.LevelInfo) logging.SetAllLoggers(logging.LevelInfo)
ctx := context.Background() ctx := context.Background()
n, sn := b(t, 1, []int{0}) n, sn := b(t, 1, []int{0})
@ -36,7 +39,7 @@ func TestDealFlow(t *testing.T, b APIBuilder) {
} }
time.Sleep(time.Second) time.Sleep(time.Second)
r := io.LimitReader(rand.New(rand.NewSource(17)), 350) r := io.LimitReader(rand.New(rand.NewSource(17)), 257)
fcid, err := client.ClientImportLocal(ctx, r) fcid, err := client.ClientImportLocal(ctx, r)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)

View File

@ -38,9 +38,9 @@ type Miner struct {
schedPost uint64 schedPost uint64
// Sealing // Sealing
sb *sectorbuilder.SectorBuilder sb *sectorbuilder.SectorBuilder
sectors *statestore.StateStore sectors *statestore.StateStore
tktFn TicketFn tktFn TicketFn
sectorIncoming chan *SectorInfo sectorIncoming chan *SectorInfo
sectorUpdated chan sectorUpdate sectorUpdated chan sectorUpdate
@ -80,7 +80,7 @@ func NewMiner(api storageMinerApi, addr address.Address, h host.Host, ds datasto
maddr: addr, maddr: addr,
h: h, h: h,
sb: sb, sb: sb,
tktFn: tktFn, tktFn: tktFn,
sectors: statestore.New(namespace.Wrap(ds, datastore.NewKey("/sectors"))), sectors: statestore.New(namespace.Wrap(ds, datastore.NewKey("/sectors"))),

View File

@ -7,9 +7,9 @@ import (
cid "github.com/ipfs/go-cid" cid "github.com/ipfs/go-cid"
xerrors "golang.org/x/xerrors" xerrors "golang.org/x/xerrors"
"github.com/filecoin-project/lotus/lib/sectorbuilder"
"github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/lib/sectorbuilder"
) )
type TicketFn func(context.Context) (*sectorbuilder.SealTicket, error) type TicketFn func(context.Context) (*sectorbuilder.SealTicket, error)
@ -27,9 +27,9 @@ func (t *SealTicket) sb() sectorbuilder.SealTicket {
type Piece struct { type Piece struct {
DealID uint64 DealID uint64
Ref string Ref string
Size uint64 Size uint64
CommP []byte CommP []byte
} }
@ -52,7 +52,7 @@ type SectorInfo struct {
CommD []byte CommD []byte
CommR []byte CommR []byte
CommRLast []byte CommRLast []byte
Ticket SealTicket Ticket SealTicket
PreCommitMessage *cid.Cid PreCommitMessage *cid.Cid
@ -219,10 +219,10 @@ func (m *Miner) newSector(ctx context.Context, sid uint64, dealID uint64, ref st
Pieces: []Piece{ Pieces: []Piece{
{ {
DealID: dealID, DealID: dealID,
Ref:ref, Ref: ref,
Size: ppi.Size, Size: ppi.Size,
CommP: ppi.CommP[:], CommP: ppi.CommP[:],
}, },
}, },
} }

View File

@ -43,11 +43,13 @@ func (m *Miner) finishPacking(ctx context.Context, sector SectorInfo) (func(*Sec
allocated += piece.Size allocated += piece.Size
} }
if allocated > m.sb.SectorSize() { ubytes := sectorbuilder.UserBytesForSectorSize(m.sb.SectorSize())
return nil, xerrors.Errorf("too much data in sector: %d > %d", allocated, m.sb.SectorSize())
if allocated > ubytes {
return nil, xerrors.Errorf("too much data in sector: %d > %d", allocated, ubytes)
} }
fillerSizes, err := fillersFromRem(m.sb.SectorSize() - allocated) fillerSizes, err := fillersFromRem(ubytes - allocated)
if err != nil { if err != nil {
return nil, err return nil, err
} }