Skip to content

Commit

Permalink
rename {changeHandlerAPI=>wdPoStCommands} + add docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
raulk committed May 15, 2021
1 parent c77f8fb commit 50360e6
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions storage/wdpost_changehandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ const (
type CompleteGeneratePoSTCb func(posts []miner.SubmitWindowedPoStParams, err error)
type CompleteSubmitPoSTCb func(err error)

type changeHandlerAPI interface {
// wdPoStCommands is the subset of the WindowPoStScheduler + full node APIs used
// by the changeHandler to execute actions and query state.
type wdPoStCommands interface {
StateMinerProvingDeadline(context.Context, address.Address, types.TipSetKey) (*dline.Info, error)

startGeneratePoST(ctx context.Context, ts *types.TipSet, deadline *dline.Info, onComplete CompleteGeneratePoSTCb) context.CancelFunc
Expand All @@ -31,13 +33,13 @@ type changeHandlerAPI interface {
}

type changeHandler struct {
api changeHandlerAPI
api wdPoStCommands
actor address.Address
proveHdlr *proveHandler
submitHdlr *submitHandler
}

func newChangeHandler(api changeHandlerAPI, actor address.Address) *changeHandler {
func newChangeHandler(api wdPoStCommands, actor address.Address) *changeHandler {
posts := newPostsCache()
p := newProver(api, posts)
s := newSubmitter(api, posts)
Expand Down Expand Up @@ -147,7 +149,7 @@ type postResult struct {

// proveHandler generates proofs
type proveHandler struct {
api changeHandlerAPI
api wdPoStCommands
posts *postsCache

postResults chan *postResult
Expand All @@ -164,7 +166,7 @@ type proveHandler struct {
}

func newProver(
api changeHandlerAPI,
api wdPoStCommands,
posts *postsCache,
) *proveHandler {
ctx, cancel := context.WithCancel(context.Background())
Expand Down Expand Up @@ -249,7 +251,7 @@ func (p *proveHandler) processPostResult(res *postResult) {
di := res.currPost.di
if res.err != nil {
// Proving failed so inform the API
p.api.failPost(res.err, res.ts, di)
p.api.recordPoStFailure(res.err, res.ts, di)
log.Warnf("Aborted window post Proving (Deadline: %+v)", di)
p.api.onAbort(res.ts, di)

Expand Down Expand Up @@ -296,7 +298,7 @@ type postInfo struct {

// submitHandler submits proofs on-chain
type submitHandler struct {
api changeHandlerAPI
api wdPoStCommands
posts *postsCache

submitResults chan *submitResult
Expand All @@ -320,7 +322,7 @@ type submitHandler struct {
}

func newSubmitter(
api changeHandlerAPI,
api wdPoStCommands,
posts *postsCache,
) *submitHandler {
ctx, cancel := context.WithCancel(context.Background())
Expand Down Expand Up @@ -489,7 +491,7 @@ func (s *submitHandler) submitIfReady(ctx context.Context, advance *types.TipSet
func (s *submitHandler) processSubmitResult(res *submitResult) {
if res.err != nil {
// Submit failed so inform the API and go back to the start state
s.api.failPost(res.err, res.pw.ts, res.pw.di)
s.api.recordPoStFailure(res.err, res.pw.ts, res.pw.di)
log.Warnf("Aborted window post Submitting (Deadline: %+v)", res.pw.di)
s.api.onAbort(res.pw.ts, res.pw.di)

Expand Down

0 comments on commit 50360e6

Please sign in to comment.