2020-04-06 18:07:26 +00:00
|
|
|
package storage
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2020-09-07 03:49:10 +00:00
|
|
|
"github.com/filecoin-project/go-state-types/abi"
|
2020-04-06 18:07:26 +00:00
|
|
|
|
|
|
|
"github.com/filecoin-project/lotus/chain/events"
|
|
|
|
"github.com/filecoin-project/lotus/chain/types"
|
2022-06-14 17:41:59 +00:00
|
|
|
sealing "github.com/filecoin-project/lotus/storage/pipeline"
|
2020-04-06 18:07:26 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var _ sealing.Events = new(EventsAdapter)
|
|
|
|
|
|
|
|
type EventsAdapter struct {
|
2020-04-06 21:03:47 +00:00
|
|
|
delegate *events.Events
|
2020-04-06 18:07:26 +00:00
|
|
|
}
|
|
|
|
|
2020-04-06 21:03:47 +00:00
|
|
|
func NewEventsAdapter(api *events.Events) EventsAdapter {
|
2020-04-06 18:07:26 +00:00
|
|
|
return EventsAdapter{delegate: api}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e EventsAdapter) ChainAt(hnd sealing.HeightHandler, rev sealing.RevertHandler, confidence int, h abi.ChainEpoch) error {
|
2021-08-04 00:10:30 +00:00
|
|
|
return e.delegate.ChainAt(context.TODO(), func(ctx context.Context, ts *types.TipSet, curH abi.ChainEpoch) error {
|
2020-04-06 18:07:26 +00:00
|
|
|
return hnd(ctx, ts.Key().Bytes(), curH)
|
|
|
|
}, func(ctx context.Context, ts *types.TipSet) error {
|
|
|
|
return rev(ctx, ts.Key().Bytes())
|
|
|
|
}, confidence, h)
|
|
|
|
}
|