rename {changeHandlerAPI=>wdPoStCommands} + add docs.
This commit is contained in:
parent
c77f8fb382
commit
50360e68ae
@ -21,7 +21,9 @@ const (
|
|||||||
type CompleteGeneratePoSTCb func(posts []miner.SubmitWindowedPoStParams, err error)
|
type CompleteGeneratePoSTCb func(posts []miner.SubmitWindowedPoStParams, err error)
|
||||||
type CompleteSubmitPoSTCb func(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)
|
StateMinerProvingDeadline(context.Context, address.Address, types.TipSetKey) (*dline.Info, error)
|
||||||
|
|
||||||
startGeneratePoST(ctx context.Context, ts *types.TipSet, deadline *dline.Info, onComplete CompleteGeneratePoSTCb) context.CancelFunc
|
startGeneratePoST(ctx context.Context, ts *types.TipSet, deadline *dline.Info, onComplete CompleteGeneratePoSTCb) context.CancelFunc
|
||||||
@ -31,13 +33,13 @@ type changeHandlerAPI interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type changeHandler struct {
|
type changeHandler struct {
|
||||||
api changeHandlerAPI
|
api wdPoStCommands
|
||||||
actor address.Address
|
actor address.Address
|
||||||
proveHdlr *proveHandler
|
proveHdlr *proveHandler
|
||||||
submitHdlr *submitHandler
|
submitHdlr *submitHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
func newChangeHandler(api changeHandlerAPI, actor address.Address) *changeHandler {
|
func newChangeHandler(api wdPoStCommands, actor address.Address) *changeHandler {
|
||||||
posts := newPostsCache()
|
posts := newPostsCache()
|
||||||
p := newProver(api, posts)
|
p := newProver(api, posts)
|
||||||
s := newSubmitter(api, posts)
|
s := newSubmitter(api, posts)
|
||||||
@ -147,7 +149,7 @@ type postResult struct {
|
|||||||
|
|
||||||
// proveHandler generates proofs
|
// proveHandler generates proofs
|
||||||
type proveHandler struct {
|
type proveHandler struct {
|
||||||
api changeHandlerAPI
|
api wdPoStCommands
|
||||||
posts *postsCache
|
posts *postsCache
|
||||||
|
|
||||||
postResults chan *postResult
|
postResults chan *postResult
|
||||||
@ -164,7 +166,7 @@ type proveHandler struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func newProver(
|
func newProver(
|
||||||
api changeHandlerAPI,
|
api wdPoStCommands,
|
||||||
posts *postsCache,
|
posts *postsCache,
|
||||||
) *proveHandler {
|
) *proveHandler {
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
@ -249,7 +251,7 @@ func (p *proveHandler) processPostResult(res *postResult) {
|
|||||||
di := res.currPost.di
|
di := res.currPost.di
|
||||||
if res.err != nil {
|
if res.err != nil {
|
||||||
// Proving failed so inform the API
|
// 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)
|
log.Warnf("Aborted window post Proving (Deadline: %+v)", di)
|
||||||
p.api.onAbort(res.ts, di)
|
p.api.onAbort(res.ts, di)
|
||||||
|
|
||||||
@ -296,7 +298,7 @@ type postInfo struct {
|
|||||||
|
|
||||||
// submitHandler submits proofs on-chain
|
// submitHandler submits proofs on-chain
|
||||||
type submitHandler struct {
|
type submitHandler struct {
|
||||||
api changeHandlerAPI
|
api wdPoStCommands
|
||||||
posts *postsCache
|
posts *postsCache
|
||||||
|
|
||||||
submitResults chan *submitResult
|
submitResults chan *submitResult
|
||||||
@ -320,7 +322,7 @@ type submitHandler struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func newSubmitter(
|
func newSubmitter(
|
||||||
api changeHandlerAPI,
|
api wdPoStCommands,
|
||||||
posts *postsCache,
|
posts *postsCache,
|
||||||
) *submitHandler {
|
) *submitHandler {
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
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) {
|
func (s *submitHandler) processSubmitResult(res *submitResult) {
|
||||||
if res.err != nil {
|
if res.err != nil {
|
||||||
// Submit failed so inform the API and go back to the start state
|
// 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)
|
log.Warnf("Aborted window post Submitting (Deadline: %+v)", res.pw.di)
|
||||||
s.api.onAbort(res.pw.ts, res.pw.di)
|
s.api.onAbort(res.pw.ts, res.pw.di)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user