-
Notifications
You must be signed in to change notification settings - Fork 884
/
module.go
48 lines (43 loc) · 1.45 KB
/
module.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package nodebuilder
import (
"context"
"go.uber.org/fx"
"github.com/celestiaorg/celestia-node/libs/fxutil"
"github.com/celestiaorg/celestia-node/nodebuilder/core"
"github.com/celestiaorg/celestia-node/nodebuilder/daser"
"github.com/celestiaorg/celestia-node/nodebuilder/fraud"
"github.com/celestiaorg/celestia-node/nodebuilder/header"
"github.com/celestiaorg/celestia-node/nodebuilder/node"
"github.com/celestiaorg/celestia-node/nodebuilder/p2p"
"github.com/celestiaorg/celestia-node/nodebuilder/rpc"
"github.com/celestiaorg/celestia-node/nodebuilder/share"
"github.com/celestiaorg/celestia-node/nodebuilder/state"
"github.com/celestiaorg/celestia-node/params"
)
func ConstructModule(tp node.Type, cfg *Config, store Store) fx.Option {
baseComponents := fx.Options(
fx.Provide(params.DefaultNetwork),
fx.Provide(params.BootstrappersFor),
fx.Provide(func(lc fx.Lifecycle) context.Context {
return fxutil.WithLifecycle(context.Background(), lc)
}),
fx.Supply(cfg),
fx.Supply(store.Config),
fx.Provide(store.Datastore),
fx.Provide(store.Keystore),
// modules provided by the node
p2p.ConstructModule(tp, &cfg.P2P),
state.ConstructModule(tp, &cfg.State),
header.ConstructModule(tp, &cfg.Header),
share.ConstructModule(tp, &cfg.Share),
rpc.ConstructModule(tp, &cfg.RPC),
core.ConstructModule(tp, &cfg.Core),
daser.ConstructModule(tp),
fraud.ConstructModule(tp),
)
return fx.Module(
"node",
fx.Supply(tp),
baseComponents,
)
}