Skip to content

Commit

Permalink
chore(api): trim the lens API to required methods
Browse files Browse the repository at this point in the history
  • Loading branch information
frrist committed Dec 11, 2020
1 parent 3a90801 commit 96fae29
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 5 deletions.
47 changes: 44 additions & 3 deletions lens/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,63 @@ package lens

import (
"context"

"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-bitfield"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/chain/vm"
"github.com/filecoin-project/specs-actors/actors/util/adt"
"github.com/ipfs/go-cid"
)

type API interface {
Store() adt.Store
api.FullNode
StoreAPI
ChainAPI
StateAPI

ComputeGasOutputs(gasUsed, gasLimit int64, baseFee, feeCap, gasPremium abi.TokenAmount) vm.GasOutputs
GetExecutedMessagesForTipset(ctx context.Context, ts, pts *types.TipSet) ([]*ExecutedMessage, error)
}

type StoreAPI interface {
Store() adt.Store
}


type ChainAPI interface {
ChainNotify(context.Context) (<-chan []*api.HeadChange, error)
ChainHead(context.Context) (*types.TipSet, error)

ChainHasObj(ctx context.Context, obj cid.Cid) (bool, error)
ChainReadObj(ctx context.Context, obj cid.Cid) ([]byte, error)

ChainGetGenesis(ctx context.Context) (*types.TipSet, error)
ChainGetTipSet(context.Context, types.TipSetKey) (*types.TipSet, error)
ChainGetTipSetByHeight(context.Context, abi.ChainEpoch, types.TipSetKey) (*types.TipSet, error)

ChainGetBlockMessages(ctx context.Context, msg cid.Cid) (*api.BlockMessages, error)
ChainGetParentMessages(ctx context.Context, blockCid cid.Cid) ([]api.Message, error)
ChainGetParentReceipts(ctx context.Context, blockCid cid.Cid) ([]*types.MessageReceipt, error)
}

type StateAPI interface {
StateGetActor(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*types.Actor, error)
StateListActors(context.Context, types.TipSetKey) ([]address.Address, error)
StateChangedActors(context.Context, cid.Cid, cid.Cid) (map[string]types.Actor, error)

StateMinerSectors(ctx context.Context, addr address.Address, bf *bitfield.BitField, tsk types.TipSetKey) ([]*miner.SectorOnChainInfo, error)
StateMinerPower(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*api.MinerPower, error)

StateMarketDeals(context.Context, types.TipSetKey) (map[string]api.MarketDeal, error)

StateReadState(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*api.ActorState, error)
StateGetReceipt(ctx context.Context, bcid cid.Cid, tsk types.TipSetKey) (*types.MessageReceipt, error)
StateVMCirculatingSupplyInternal(context.Context, types.TipSetKey) (api.CirculatingSupply, error)

}

type APICloser func()

type APIOpener interface {
Expand Down
4 changes: 2 additions & 2 deletions tasks/actorstate/actorstate.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ func (p *ActorStateProcessor) Run(ctx context.Context) error {
})
}

func (p *ActorStateProcessor) processBatch(ctx context.Context, node lens.API) (bool, error) {
func (p *ActorStateProcessor) processBatch(ctx context.Context, node ActorStateAPI) (bool, error) {
// the actor represents the "raw" actor data model that is persisted
// this gets overridden with the specific actor type once we know
// which it is.
Expand Down Expand Up @@ -303,7 +303,7 @@ func (p *ActorStateProcessor) processBatch(ctx context.Context, node lens.API) (
return false, nil
}

func (p *ActorStateProcessor) processActor(ctx context.Context, node lens.API, info ActorInfo) error {
func (p *ActorStateProcessor) processActor(ctx context.Context, node ActorStateAPI, info ActorInfo) error {
ctx, span := global.Tracer("").Start(ctx, "ActorStateProcessor.processActor")
defer span.End()

Expand Down

0 comments on commit 96fae29

Please sign in to comment.