diff --git a/chain/events/state/fastapi.go b/chain/events/state/fastapi.go new file mode 100644 index 000000000..9375d9d78 --- /dev/null +++ b/chain/events/state/fastapi.go @@ -0,0 +1,34 @@ +package state + +import ( + "context" + + "github.com/filecoin-project/go-address" + + "github.com/filecoin-project/lotus/chain/types" +) + +type FastChainApiAPI interface { + ChainAPI + + ChainGetTipSet(context.Context, types.TipSetKey) (*types.TipSet, error) +} + +type fastAPI struct { + FastChainApiAPI +} + +func WrapFastAPI(api FastChainApiAPI) ChainAPI { + return &fastAPI{ + api, + } +} + +func (a *fastAPI) StateGetActor(ctx context.Context, actor address.Address, tsk types.TipSetKey) (*types.Actor, error) { + ts, err := a.FastChainApiAPI.ChainGetTipSet(ctx, tsk) + if err != nil { + return nil, err + } + + return a.FastChainApiAPI.StateGetActor(ctx, actor, ts.Parents()) +} diff --git a/markets/storageadapter/client.go b/markets/storageadapter/client.go index af21c8860..36fe0d771 100644 --- a/markets/storageadapter/client.go +++ b/markets/storageadapter/client.go @@ -57,7 +57,7 @@ func NewClientNodeAdapter(stateapi full.StateAPI, chain full.ChainAPI, mpool ful fundmgr: fundmgr, ev: events.NewEvents(context.TODO(), capi), - dsMatcher: newDealStateMatcher(state.NewStatePredicates(capi)), + dsMatcher: newDealStateMatcher(state.NewStatePredicates(state.WrapFastAPI(capi))), } } diff --git a/markets/storageadapter/provider.go b/markets/storageadapter/provider.go index cd6c2d69e..ecef1a584 100644 --- a/markets/storageadapter/provider.go +++ b/markets/storageadapter/provider.go @@ -60,7 +60,7 @@ func NewProviderNodeAdapter(fc *config.MinerFeeConfig) func(dag dtypes.StagingDA dag: dag, secb: secb, ev: events.NewEvents(context.TODO(), full), - dsMatcher: newDealStateMatcher(state.NewStatePredicates(full)), + dsMatcher: newDealStateMatcher(state.NewStatePredicates(state.WrapFastAPI(full))), } if fc != nil { na.publishSpec = &api.MessageSendSpec{MaxFee: abi.TokenAmount(fc.MaxPublishDealsFee)}