ceremonyclient/node/app/wire.go

49 lines
996 B
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/keys"
"source.quilibrium.com/quilibrium/monorepo/node/p2p"
)
func debugLogger() *zap.Logger {
log, err := zap.NewDevelopment()
if err != nil {
panic(err)
}
return log
}
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)),
)
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
)
2024-08-08 05:41:46 +00:00
func NewNode(*config.Config) (*Node, error) {
panic(wire.Build(
debugLoggerSet,
keyManagerSet,
2023-09-09 23:45:47 +00:00
pubSubSet,
newNode,
))
}