Merge pull request #2 from filecoin-project/feat/ticket-fn-takes-token

ticket-acquiring function takes tipset identifier
This commit is contained in:
Erin Swenson-Healey 2020-04-08 07:39:38 -07:00 committed by GitHub
commit 5326cb55b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 3 deletions

View File

@ -35,7 +35,6 @@ type SealingAPI interface {
SendMsg(ctx context.Context, from, to address.Address, method abi.MethodNum, value, gasPrice big.Int, gasLimit int64, params []byte) (cid.Cid, error) SendMsg(ctx context.Context, from, to address.Address, method abi.MethodNum, value, gasPrice big.Int, gasLimit int64, params []byte) (cid.Cid, error)
ChainHead(ctx context.Context) (TipSetToken, abi.ChainEpoch, error) ChainHead(ctx context.Context) (TipSetToken, abi.ChainEpoch, error)
ChainGetRandomness(ctx context.Context, tok TipSetToken, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte) (abi.Randomness, error) ChainGetRandomness(ctx context.Context, tok TipSetToken, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte) (abi.Randomness, error)
ChainReadObj(context.Context, cid.Cid) ([]byte, error)
} }
type Sealing struct { type Sealing struct {

View File

@ -47,6 +47,12 @@ func (m *Sealing) handlePacking(ctx statemachine.Context, sector SectorInfo) err
} }
func (m *Sealing) handlePreCommit1(ctx statemachine.Context, sector SectorInfo) error { func (m *Sealing) handlePreCommit1(ctx statemachine.Context, sector SectorInfo) error {
tok, _, err := m.api.ChainHead(ctx.Context())
if err != nil {
log.Errorf("handlePreCommit1: api error, not proceeding: %+v", err)
return nil
}
if err := checkPieces(ctx.Context(), sector, m.api); err != nil { // Sanity check state if err := checkPieces(ctx.Context(), sector, m.api); err != nil { // Sanity check state
switch err.(type) { switch err.(type) {
case *ErrApi: case *ErrApi:
@ -62,7 +68,7 @@ func (m *Sealing) handlePreCommit1(ctx statemachine.Context, sector SectorInfo)
} }
log.Infow("performing sector replication...", "sector", sector.SectorNumber) log.Infow("performing sector replication...", "sector", sector.SectorNumber)
ticketValue, ticketEpoch, err := m.tktFn(ctx.Context()) ticketValue, ticketEpoch, err := m.tktFn(ctx.Context(), tok)
if err != nil { if err != nil {
return ctx.Send(SectorSealPreCommitFailed{xerrors.Errorf("getting ticket failed: %w", err)}) return ctx.Send(SectorSealPreCommitFailed{xerrors.Errorf("getting ticket failed: %w", err)})
} }

View File

@ -98,7 +98,7 @@ func (t *SectorInfo) existingPieces() []abi.UnpaddedPieceSize {
return out return out
} }
type TicketFn func(context.Context) (abi.SealRandomness, abi.ChainEpoch, error) type TicketFn func(ctx context.Context, tok TipSetToken) (abi.SealRandomness, abi.ChainEpoch, error)
type SectorIDCounter interface { type SectorIDCounter interface {
Next() (abi.SectorNumber, error) Next() (abi.SectorNumber, error)