ceremonyclient/node/app/node.go

60 lines
1.1 KiB
Go
Raw Normal View History

2023-09-03 23:47:09 +00:00
package app
import (
"go.uber.org/zap"
2024-08-08 05:41:46 +00:00
"source.quilibrium.com/quilibrium/monorepo/go-libp2p-blossomsub/pb"
2023-10-28 02:23:55 +00:00
"source.quilibrium.com/quilibrium/monorepo/node/keys"
"source.quilibrium.com/quilibrium/monorepo/node/p2p"
2023-09-03 23:47:09 +00:00
)
type Node struct {
2024-08-08 05:41:46 +00:00
logger *zap.Logger
keyManager keys.KeyManager
pubSub p2p.PubSub
quit chan struct{}
}
2023-09-03 23:47:09 +00:00
func newNode(
logger *zap.Logger,
2023-10-28 02:23:55 +00:00
keyManager keys.KeyManager,
pubSub p2p.PubSub,
2023-09-03 23:47:09 +00:00
) (*Node, error) {
return &Node{
2024-08-08 05:41:46 +00:00
logger: logger,
keyManager: keyManager,
pubSub: pubSub,
quit: make(chan struct{}),
2023-09-03 23:47:09 +00:00
}, nil
}
2024-08-08 05:41:46 +00:00
func (d *Node) Start() {
d.pubSub.Subscribe(
[]byte{
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
},
func(message *pb.Message) error { return nil },
)
<-d.quit
}
2024-08-08 05:41:46 +00:00
func (d *Node) Stop() {
go func() {
d.quit <- struct{}{}
}()
}
func (n *Node) GetLogger() *zap.Logger {
return n.logger
}
2023-10-28 02:23:55 +00:00
func (n *Node) GetKeyManager() keys.KeyManager {
return n.keyManager
}
func (n *Node) GetPubSub() p2p.PubSub {
return n.pubSub
}