Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle sector id in the OnDealSectorCommitted callback #58

Merged
merged 1 commit into from
Jan 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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