Skip to content

Commit

Permalink
fix(node): fix bug where Full Node was a light Node
Browse files Browse the repository at this point in the history
  • Loading branch information
Wondertan committed Sep 30, 2021
1 parent a9cfd66 commit b739077
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
3 changes: 0 additions & 3 deletions node/light.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ func lightComponents(cfg *Config, repo Repository) fx.Option {
return fx.Options(
// manual providing
fx.Provide(context.Background),
fx.Provide(func() Type {
return Light
}),
fx.Provide(func() *Config {
return cfg
}),
Expand Down
9 changes: 6 additions & 3 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ func New(tp Type, repo Repository) (*Node, error) {

switch tp {
case Full:
return newNode(fullComponents(cfg, repo))
return newNode(tp, fullComponents(cfg, repo))
case Light:
return newNode(lightComponents(cfg, repo))
return newNode(tp, lightComponents(cfg, repo))
default:
panic("node: unknown Node Type")
}
Expand Down Expand Up @@ -122,12 +122,15 @@ func (n *Node) Stop(ctx context.Context) error {
// DI options allow initializing the Node with a customized set of components and services.
// NOTE: newNode is currently meant to be used privately to create various custom Node types e.g. full, unless we
// decide to give package users the ability to create custom node types themselves.
func newNode(opts ...fx.Option) (*Node, error) {
func newNode(tp Type, opts ...fx.Option) (*Node, error) {
node := new(Node)
node.app = fx.New(
fx.NopLogger,
fx.Extract(node),
fx.Options(opts...),
fx.Provide(func() Type {
return tp
}),
)
return node, node.app.Err()
}
4 changes: 2 additions & 2 deletions node/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ var typeToString = map[Type]string{

// typeToString maps strings representations of all valid Types.
var stringToType = map[string]Type{
"Full": Full,
"Full": Full,
"Light": Light,
}
}

0 comments on commit b739077

Please sign in to comment.