Skip to content

Commit

Permalink
Handle sector id in the OnDealSectorCommitted callback
Browse files Browse the repository at this point in the history
  • Loading branch information
ingar authored and hannahhoward committed Jan 28, 2020
1 parent 2249baf commit 37a36a9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
2 changes: 1 addition & 1 deletion storagemarket/impl/client_states.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (c *Client) staged(ctx context.Context, deal ClientDeal) (func(*ClientDeal)
}

func (c *Client) sealing(ctx context.Context, deal ClientDeal) (func(*ClientDeal), error) {
cb := func(err error) {
cb := func(_ uint64, err error) {
select {
case c.updated <- clientDealUpdate{
newState: storagemarket.StorageDealActive,
Expand Down
15 changes: 6 additions & 9 deletions storagemarket/impl/provider_states.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func (p *Provider) staged(ctx context.Context, deal MinerDeal) (func(*MinerDeal)
return nil, err
}
paddedReader, paddedSize := padreader.NewPaddedReader(file, uint64(file.Size()))
sectorID, err := p.spn.OnDealComplete(
err = p.spn.OnDealComplete(
ctx,
storagemarket.MinerDeal{
Client: deal.Client,
Expand All @@ -191,25 +191,22 @@ func (p *Provider) staged(ctx context.Context, deal MinerDeal) (func(*MinerDeal)
paddedReader,
)

if err != nil {
return nil, err
}

return func(deal *MinerDeal) {
deal.SectorID = sectorID
}, nil
return nil, err
}

// SEALING

func (p *Provider) sealing(ctx context.Context, deal MinerDeal) (func(*MinerDeal), error) {
// TODO: consider waiting for seal to happen
cb := func(err error) {
cb := func(sectorId uint64, err error) {
select {
case p.updated <- minerDealUpdate{
newState: storagemarket.StorageDealActive,
id: deal.ProposalCid,
err: err,
mut: func(deal *MinerDeal) {
deal.SectorID = sectorId
},
}:
case <-p.stop:
}
Expand Down
5 changes: 2 additions & 3 deletions storagemarket/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,7 @@ type StorageProviderNode interface {
ListProviderDeals(ctx context.Context, addr address.Address) ([]StorageDeal, error)

// Called when a deal is complete and on chain, and data has been transferred and is ready to be added to a sector
// returns sector id
OnDealComplete(ctx context.Context, deal MinerDeal, pieceSize uint64, pieceReader io.Reader) (uint64, error)
OnDealComplete(ctx context.Context, deal MinerDeal, pieceSize uint64, pieceReader io.Reader) error

// returns the worker address associated with a miner
GetMinerWorker(ctx context.Context, miner address.Address) (address.Address, error)
Expand All @@ -245,7 +244,7 @@ type StorageProviderNode interface {
LocatePieceForDealWithinSector(ctx context.Context, dealID uint64) (sectorID uint64, offset uint64, length uint64, err error)
}

type DealSectorCommittedCallback func(error)
type DealSectorCommittedCallback func(sectorId uint64, err error)

// Node dependencies for a StorageClient
type StorageClientNode interface {
Expand Down

0 comments on commit 37a36a9

Please sign in to comment.