rename {changeHandlerAPI=>wdPoStCommands} + add docs.

This commit is contained in:
Raúl Kripalani 2021-05-14 21:04:35 +01:00
parent c77f8fb382
commit 50360e68ae

View File

@ -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
@ -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)
@ -147,7 +149,7 @@ type postResult struct {
// proveHandler generates proofs
type proveHandler struct {
api changeHandlerAPI
api wdPoStCommands
posts *postsCache
postResults chan *postResult
@ -164,7 +166,7 @@ type proveHandler struct {
}
func newProver(
api changeHandlerAPI,
api wdPoStCommands,
posts *postsCache,
) *proveHandler {
ctx, cancel := context.WithCancel(context.Background())
@ -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)
@ -296,7 +298,7 @@ type postInfo struct {
// submitHandler submits proofs on-chain
type submitHandler struct {
api changeHandlerAPI
api wdPoStCommands
posts *postsCache
submitResults chan *submitResult
@ -320,7 +322,7 @@ type submitHandler struct {
}
func newSubmitter(
api changeHandlerAPI,
api wdPoStCommands,
posts *postsCache,
) *submitHandler {
ctx, cancel := context.WithCancel(context.Background())
@ -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)