lotus/storage/adapter_events.go

30 lines
838 B
Go
Raw Normal View History

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