From b73907766bb57d6aa9ac24746181d0b1f67cf520 Mon Sep 17 00:00:00 2001 From: Wondertan Date: Thu, 30 Sep 2021 19:40:11 +0300 Subject: [PATCH] fix(node): fix bug where Full Node was a light Node --- node/light.go | 3 --- node/node.go | 9 ++++++--- node/type.go | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/node/light.go b/node/light.go index 2440f4f494..03bb107d3e 100644 --- a/node/light.go +++ b/node/light.go @@ -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 }), diff --git a/node/node.go b/node/node.go index 5feee3aa29..e680af185a 100644 --- a/node/node.go +++ b/node/node.go @@ -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") } @@ -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() } diff --git a/node/type.go b/node/type.go index fad9f22f89..58469bb991 100644 --- a/node/type.go +++ b/node/type.go @@ -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, -} \ No newline at end of file +}