fix: support node instantiation in external packages

- implement ChainGetPath on ChainModuleAPI
This commit is contained in:
frrist 2021-10-13 15:24:28 -07:00
parent 6d8a6c480f
commit 6cd6732225
2 changed files with 12 additions and 0 deletions

View File

@ -374,6 +374,13 @@ func WithRepoType(repoType repo.RepoType) func(s *Settings) error {
} }
} }
func WithEnableLibp2pNode(enable bool) func(s *Settings) error {
return func(s *Settings) error {
s.enableLibp2pNode = enable
return nil
}
}
func WithInvokesKey(i invoke, resApi interface{}) func(s *Settings) error { func WithInvokesKey(i invoke, resApi interface{}) func(s *Settings) error {
return func(s *Settings) error { return func(s *Settings) error {
s.invokes[i] = fx.Populate(resApi) s.invokes[i] = fx.Populate(resApi)

View File

@ -51,6 +51,7 @@ type ChainModuleAPI interface {
ChainGetTipSetByHeight(ctx context.Context, h abi.ChainEpoch, tsk types.TipSetKey) (*types.TipSet, error) ChainGetTipSetByHeight(ctx context.Context, h abi.ChainEpoch, tsk types.TipSetKey) (*types.TipSet, error)
ChainGetTipSetAfterHeight(ctx context.Context, h abi.ChainEpoch, tsk types.TipSetKey) (*types.TipSet, error) ChainGetTipSetAfterHeight(ctx context.Context, h abi.ChainEpoch, tsk types.TipSetKey) (*types.TipSet, error)
ChainReadObj(context.Context, cid.Cid) ([]byte, error) ChainReadObj(context.Context, cid.Cid) ([]byte, error)
ChainGetPath(ctx context.Context, from, to types.TipSetKey) ([]*api.HeadChange, error)
} }
var _ ChainModuleAPI = *new(api.FullNode) var _ ChainModuleAPI = *new(api.FullNode)
@ -105,6 +106,10 @@ func (m *ChainModule) ChainGetTipSet(ctx context.Context, key types.TipSetKey) (
return m.Chain.LoadTipSet(key) return m.Chain.LoadTipSet(key)
} }
func (m *ChainModule) ChainGetPath(ctx context.Context, from, to types.TipSetKey) ([]*api.HeadChange, error) {
return m.Chain.GetPath(ctx, from, to)
}
func (m *ChainModule) ChainGetBlockMessages(ctx context.Context, msg cid.Cid) (*api.BlockMessages, error) { func (m *ChainModule) ChainGetBlockMessages(ctx context.Context, msg cid.Cid) (*api.BlockMessages, error) {
b, err := m.Chain.GetBlock(msg) b, err := m.Chain.GetBlock(msg)
if err != nil { if err != nil {