ceremonyclient/node/app/wire.go

128 lines
2.9 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"
"source.quilibrium.com/quilibrium/monorepo/node/consensus/master"
2024-02-13 07:04:56 +00:00
"source.quilibrium.com/quilibrium/monorepo/node/consensus/time"
"source.quilibrium.com/quilibrium/monorepo/node/crypto"
2023-09-03 23:47:09 +00:00
"source.quilibrium.com/quilibrium/monorepo/node/keys"
"source.quilibrium.com/quilibrium/monorepo/node/p2p"
2024-03-01 07:12:31 +00:00
"source.quilibrium.com/quilibrium/monorepo/node/protobufs"
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
}
func debugLogger() *zap.Logger {
log, err := zap.NewDevelopment()
if err != nil {
panic(err)
}
return log
}
2023-09-03 23:47:09 +00:00
var loggerSet = wire.NewSet(
logger,
)
var debugLoggerSet = wire.NewSet(
debugLogger,
)
2023-09-03 23:47:09 +00:00
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,
2024-01-03 07:31:42 +00:00
wire.Bind(new(store.KVDB), new(*store.PebbleDB)),
2023-09-09 23:45:47 +00:00
store.NewPebbleClockStore,
2023-09-25 02:43:35 +00:00
store.NewPebbleKeyStore,
store.NewPebbleDataProofStore,
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)),
wire.Bind(new(store.DataProofStore), new(*store.PebbleDataProofStore)),
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"),
2024-03-21 07:14:45 +00:00
p2p.NewInMemoryPeerInfoManager,
2023-09-03 23:47:09 +00:00
p2p.NewBlossomSub,
wire.Bind(new(p2p.PubSub), new(*p2p.BlossomSub)),
2024-03-21 07:14:45 +00:00
wire.Bind(new(p2p.PeerInfoManager), new(*p2p.InMemoryPeerInfoManager)),
2023-09-03 23:47:09 +00:00
)
var engineSet = wire.NewSet(
2024-01-03 07:31:42 +00:00
wire.FieldsOf(new(*config.Config), "Engine"),
2024-02-13 07:04:56 +00:00
crypto.NewWesolowskiFrameProver,
wire.Bind(new(crypto.FrameProver), new(*crypto.WesolowskiFrameProver)),
crypto.NewKZGInclusionProver,
wire.Bind(new(crypto.InclusionProver), new(*crypto.KZGInclusionProver)),
time.NewMasterTimeReel,
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 NewDHTNode(*config.Config) (*DHTNode, error) {
panic(wire.Build(
debugLoggerSet,
pubSubSet,
newDHTNode,
))
}
func NewDebugNode(*config.Config, *protobufs.SelfTestReport) (*Node, error) {
panic(wire.Build(
debugLoggerSet,
keyManagerSet,
storeSet,
pubSubSet,
engineSet,
consensusSet,
newNode,
))
}
2024-03-01 07:12:31 +00:00
func NewNode(*config.Config, *protobufs.SelfTestReport) (*Node, error) {
2023-09-09 23:45:47 +00:00
panic(wire.Build(
loggerSet,
keyManagerSet,
storeSet,
pubSubSet,
engineSet,
consensusSet,
newNode,
))
}
func NewDBConsole(*config.Config) (*DBConsole, error) {
panic(wire.Build(newDBConsole))
2023-09-03 23:47:09 +00:00
}
func NewClockStore(*config.Config) (store.ClockStore, error) {
panic(wire.Build(loggerSet, storeSet))
}