From 728afc0587d2893a1d4674e98e4d44c21fc74842 Mon Sep 17 00:00:00 2001 From: Dirk McCormick Date: Thu, 25 Jun 2020 12:46:43 -0400 Subject: [PATCH] refactor: remove state API example --- chain/events/state/state.go | 57 ------------------------------------- 1 file changed, 57 deletions(-) delete mode 100644 chain/events/state/state.go diff --git a/chain/events/state/state.go b/chain/events/state/state.go deleted file mode 100644 index 75041ad79..000000000 --- a/chain/events/state/state.go +++ /dev/null @@ -1,57 +0,0 @@ -package state - -import ( - "context" - - "github.com/filecoin-project/lotus/chain/store" - "github.com/filecoin-project/specs-actors/actors/abi" - - "github.com/filecoin-project/lotus/api" - "github.com/filecoin-project/lotus/chain/types" -) - -type StateWatcher struct { -} - -type WatcherAPI interface { - ChainNotify(context.Context) (<-chan []*api.HeadChange, error) -} - -type UserData interface{} - -type DiffFunc func(ctx context.Context, oldState, newState *types.TipSet) (changed bool, user UserData, err error) - -type Callback func(ctx context.Context, oldState, newState *types.TipSet, events interface{}) - -type RevertHandler func(ctx context.Context, ts *types.TipSet) error - -/* -w := NewWatcher(api, OnActorChange(t04, OnDealStateChange(123)), cb) -*/ -func NewWatcher(ctx context.Context, api WatcherAPI, d DiffFunc, apply Callback, revert RevertHandler, confidence, timeout abi.ChainEpoch) { - go func() { - notifs, err := api.ChainNotify(ctx) - if err != nil { - // bad - return - } - - curTs := (<-notifs)[0].Val - d(ctx, curTs, curTs) - - for { - select { - case update := <-notifs: - for i, change := range update { - switch change.Type { - case store.HCApply: - d(ctx, curTs, change.Val) - case store.HCRevert: - - } - } - } - } - - }() -}