Skip to content

Commit

Permalink
opt: Generate indexes using separate goroutines
Browse files Browse the repository at this point in the history
  • Loading branch information
simlecode committed May 5, 2023
1 parent 91e9c12 commit 83e75c3
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions storageprovider/deal_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -529,14 +529,16 @@ func (storageDealPorcess *StorageDealProcessImpl) HandleOff(ctx context.Context,
}
}

// Register the deal data as a "shard" with the DAG store. Later it can be
// fetched from the DAG store during retrieval.
if err := stores.RegisterShardSync(ctx, storageDealPorcess.dagStore, deal.Proposal.PieceCID, carFilePath, true); err != nil {
err = fmt.Errorf("failed to activate shard: %w", err)
log.Error(err)
} else {
log.Infof("register shard successfully. deal:%d, proposalCid:%s, pieceCid:%s", deal.DealID, deal.ProposalCid, deal.Proposal.PieceCID)
}
go func() {
log.Infof("start register shard. deal:%d, proposalCid:%s, pieceCid:%s", deal.DealID, deal.ProposalCid, deal.Proposal.PieceCID)
// Register the deal data as a "shard" with the DAG store. Later it can be
// fetched from the DAG store during retrieval.
if err := stores.RegisterShardSync(ctx, storageDealPorcess.dagStore, deal.Proposal.PieceCID, carFilePath, true); err != nil {
log.Error("failed to register shard: %v", err)
} else {
log.Infof("register shard successfully. deal:%d, proposalCid:%s, pieceCid:%s", deal.DealID, deal.ProposalCid, deal.Proposal.PieceCID)
}
}()

log.Infow("successfully handed off deal to sealing subsystem", "pieceCid", deal.Proposal.PieceCID, "proposalCid", deal.ProposalCid)
deal.AvailableForRetrieval = true
Expand Down

0 comments on commit 83e75c3

Please sign in to comment.