Skip to content

Commit

Permalink
create DDProvider config (#1679)
Browse files Browse the repository at this point in the history
  • Loading branch information
LexLuthr authored Sep 7, 2023
1 parent bdd024b commit 892ae26
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
8 changes: 7 additions & 1 deletion node/modules/directdeals.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/filecoin-project/boost/storagemarket/sealingpipeline"
"github.com/filecoin-project/boost/storagemarket/types"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/lotus/api/v1api"
"github.com/filecoin-project/lotus/storage/sectorblocks"
"github.com/libp2p/go-libp2p/core/host"
Expand Down Expand Up @@ -54,7 +55,12 @@ func NewDirectDealsProvider(provAddr address.Address, cfg *config.Boost) func(lc

//func NewDirectDealsProvider(fullnodeApi v1api.FullNode, pieceAdder types.PieceAdder, directDealsDB *db.DirectDataDB, dealLogger *logs.DealLogger) *DirectDealsProvider {

prov := storagemarket.NewDirectDealsProvider(fullnodeApi, secb, commpc, directDealsDB, dl)
ddpCfg := storagemarket.DDPConfig{
StartEpochSealingBuffer: abi.ChainEpoch(cfg.Dealmaking.StartEpochSealingBuffer),
RemoteCommp: cfg.Dealmaking.RemoteCommp,
}

prov := storagemarket.NewDirectDealsProvider(ddpCfg, fullnodeApi, secb, commpc, directDealsDB, dl)
return prov, nil
}
}
20 changes: 13 additions & 7 deletions storagemarket/direct_deals_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,16 @@ import (

//var log = logging.Logger("direct-deals-providers")

type DDPConfig struct {
// Whether to do commp on the Boost node (local) or the sealing node (remote)
RemoteCommp bool
// Minimum start epoch buffer to give time for sealing of sector with deal
StartEpochSealingBuffer abi.ChainEpoch
}

type DirectDealsProvider struct {
ctx context.Context // context to be stopped when stopping boostd
config DDPConfig
ctx context.Context // context to be stopped when stopping boostd

fullnodeApi v1api.FullNode
pieceAdder types.PieceAdder
Expand All @@ -44,15 +52,13 @@ type DirectDealsProvider struct {

dealLogger *logs.DealLogger

startEpochSealingBuffer abi.ChainEpoch // TODO: move to config and init properly
remoteCommp bool

runningLk sync.RWMutex
running map[uuid.UUID]struct{}
}

func NewDirectDealsProvider(fullnodeApi v1api.FullNode, pieceAdder types.PieceAdder, commpCalc smtypes.CommpCalculator, directDealsDB *db.DirectDataDB, dealLogger *logs.DealLogger) *DirectDealsProvider {
func NewDirectDealsProvider(cfg DDPConfig, fullnodeApi v1api.FullNode, pieceAdder types.PieceAdder, commpCalc smtypes.CommpCalculator, directDealsDB *db.DirectDataDB, dealLogger *logs.DealLogger) *DirectDealsProvider {
return &DirectDealsProvider{
config: cfg,
fullnodeApi: fullnodeApi,
pieceAdder: pieceAdder,
commpCalc: commpCalc,
Expand Down Expand Up @@ -95,7 +101,7 @@ func (ddp *DirectDealsProvider) Accept(ctx context.Context, entry *types.DirectD

log.Infow("chain head", "epoch", chainHead)

if chainHead.Height()+ddp.startEpochSealingBuffer > entry.StartEpoch {
if chainHead.Height()+ddp.config.StartEpochSealingBuffer > entry.StartEpoch {
return &api.ProviderDealRejectionInfo{
Accepted: false,
Reason: fmt.Sprintf(
Expand Down Expand Up @@ -281,7 +287,7 @@ func (ddp *DirectDealsProvider) execDeal(ctx context.Context, entry *smtypes.Dir
// TODO: should we be passing pieceSize here ??!?
pieceSize := abi.UnpaddedPieceSize(fstat.Size())

generatedPieceInfo, dmErr := generatePieceCommitment(ctx, ddp.commpCalc, throttle, entry.InboundFilePath, pieceSize.Padded(), ddp.remoteCommp)
generatedPieceInfo, dmErr := generatePieceCommitment(ctx, ddp.commpCalc, throttle, entry.InboundFilePath, pieceSize.Padded(), ddp.config.RemoteCommp)
if dmErr != nil {
return &dealMakingError{
retry: types.DealRetryManual,
Expand Down

0 comments on commit 892ae26

Please sign in to comment.