ceremonyclient/node/app/wire.go

90 lines
2.1 KiB
Go
Raw Normal View History

2023-09-03 23:47:09 +00:00
//go:build wireinject
// +build wireinject
package app
import (
"github.com/google/wire"
"go.uber.org/zap"
"source.quilibrium.com/quilibrium/monorepo/node/config"
"source.quilibrium.com/quilibrium/monorepo/node/consensus"
2023-09-25 02:43:35 +00:00
ceremonyConsensus "source.quilibrium.com/quilibrium/monorepo/node/consensus/ceremony"
2023-09-03 23:47:09 +00:00
"source.quilibrium.com/quilibrium/monorepo/node/consensus/master"
2023-09-25 02:43:35 +00:00
"source.quilibrium.com/quilibrium/monorepo/node/execution/ceremony"
2023-09-03 23:47:09 +00:00
"source.quilibrium.com/quilibrium/monorepo/node/keys"
"source.quilibrium.com/quilibrium/monorepo/node/p2p"
2023-09-09 23:45:47 +00:00
"source.quilibrium.com/quilibrium/monorepo/node/store"
2023-09-03 23:47:09 +00:00
)
func logger() *zap.Logger {
log, err := zap.NewProduction()
if err != nil {
panic(err)
}
return log
}
var loggerSet = wire.NewSet(
logger,
)
var keyManagerSet = wire.NewSet(
wire.FieldsOf(new(*config.Config), "Key"),
keys.NewFileKeyManager,
wire.Bind(new(keys.KeyManager), new(*keys.FileKeyManager)),
)
2023-09-09 23:45:47 +00:00
var storeSet = wire.NewSet(
wire.FieldsOf(new(*config.Config), "DB"),
store.NewPebbleDB,
store.NewPebbleClockStore,
2023-09-25 02:43:35 +00:00
store.NewPebbleKeyStore,
2023-09-09 23:45:47 +00:00
wire.Bind(new(store.ClockStore), new(*store.PebbleClockStore)),
2023-09-25 02:43:35 +00:00
wire.Bind(new(store.KeyStore), new(*store.PebbleKeyStore)),
2023-09-09 23:45:47 +00:00
)
2023-09-03 23:47:09 +00:00
var pubSubSet = wire.NewSet(
wire.FieldsOf(new(*config.Config), "P2P"),
p2p.NewBlossomSub,
wire.Bind(new(p2p.PubSub), new(*p2p.BlossomSub)),
)
2023-09-25 02:43:35 +00:00
var dataConsensusSet = wire.NewSet(
wire.FieldsOf(new(*config.Config), "Engine"),
ceremonyConsensus.NewCeremonyDataClockConsensusEngine,
wire.Bind(
new(consensus.DataConsensusEngine),
new(*ceremonyConsensus.CeremonyDataClockConsensusEngine),
),
)
2023-09-03 23:47:09 +00:00
var engineSet = wire.NewSet(
2023-09-25 02:43:35 +00:00
ceremony.NewCeremonyExecutionEngine,
2023-09-03 23:47:09 +00:00
)
var consensusSet = wire.NewSet(
master.NewMasterClockConsensusEngine,
2023-09-09 23:45:47 +00:00
wire.Bind(
new(consensus.ConsensusEngine),
new(*master.MasterClockConsensusEngine),
),
2023-09-03 23:47:09 +00:00
)
func NewNode(*config.Config) (*Node, error) {
2023-09-09 23:45:47 +00:00
panic(wire.Build(
loggerSet,
keyManagerSet,
storeSet,
pubSubSet,
engineSet,
2023-09-25 02:43:35 +00:00
dataConsensusSet,
2023-09-09 23:45:47 +00:00
consensusSet,
newNode,
))
}
func NewDBConsole(*config.Config) (*DBConsole, error) {
panic(wire.Build(loggerSet, storeSet, newDBConsole))
2023-09-03 23:47:09 +00:00
}