Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: support node instantiation in external packages #7511

Merged
merged 1 commit into from
Oct 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions node/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Comment on lines +377 to +383
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

func WithInvokesKey(i invoke, resApi interface{}) func(s *Settings) error {
return func(s *Settings) error {
s.invokes[i] = fx.Populate(resApi)
Expand Down
5 changes: 5 additions & 0 deletions node/impl/full/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {
Expand Down