From 6cd67322257e36aa464ec57e402ba9140af93021 Mon Sep 17 00:00:00 2001 From: frrist Date: Wed, 13 Oct 2021 15:24:28 -0700 Subject: [PATCH] fix: support node instantiation in external packages - implement ChainGetPath on ChainModuleAPI --- node/builder.go | 7 +++++++ node/impl/full/chain.go | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/node/builder.go b/node/builder.go index 6c42aad2d22..3f2e5950331 100644 --- a/node/builder.go +++ b/node/builder.go @@ -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 { return func(s *Settings) error { s.invokes[i] = fx.Populate(resApi) diff --git a/node/impl/full/chain.go b/node/impl/full/chain.go index e8d4033372d..4ffbe0e6376 100644 --- a/node/impl/full/chain.go +++ b/node/impl/full/chain.go @@ -51,6 +51,7 @@ type ChainModuleAPI interface { 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) ChainReadObj(context.Context, cid.Cid) ([]byte, error) + ChainGetPath(ctx context.Context, from, to types.TipSetKey) ([]*api.HeadChange, error) } var _ ChainModuleAPI = *new(api.FullNode) @@ -105,6 +106,10 @@ func (m *ChainModule) ChainGetTipSet(ctx context.Context, key types.TipSetKey) ( 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) { b, err := m.Chain.GetBlock(msg) if err != nil {