fix: ensure registry is setup in construction

This commit is contained in:
Derrick Hammer 2024-01-10 06:42:17 -05:00
parent 7578665ba4
commit 65727b8cc5
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
3 changed files with 8 additions and 5 deletions

View File

@ -52,7 +52,7 @@ func NewNode(config *config.NodeConfig) interfaces.Node {
hashQueryRoutingTable: structs.NewMap(), hashQueryRoutingTable: structs.NewMap(),
httpClient: resty.New(), httpClient: resty.New(),
} }
n.services = NewServices(service.NewP2P(n)) n.services = NewServices(service.NewP2P(n), service.NewRegistry(n))
return n return n
} }

View File

@ -23,8 +23,11 @@ func (s *ServicesImpl) Registry() interfaces.RegistryService {
return s.registry return s.registry
} }
func NewServices(p2p interfaces.P2PService) *ServicesImpl { func NewServices(p2p interfaces.P2PService, registry interfaces.RegistryService) interfaces.Services {
return &ServicesImpl{p2p: p2p} return &ServicesImpl{
p2p: p2p,
registry: registry,
}
} }
func (s *ServicesImpl) P2P() interfaces.P2PService { func (s *ServicesImpl) P2P() interfaces.P2PService {

View File

@ -44,10 +44,10 @@ func (r *RegistryImpl) Init() error {
return utils.CreateBucket(registryBucketName, r.node.Db()) return utils.CreateBucket(registryBucketName, r.node.Db())
} }
func NewRegistry(node interfaces.Node, logger *zap.Logger) *RegistryImpl { func NewRegistry(node interfaces.Node) *RegistryImpl {
return &RegistryImpl{ return &RegistryImpl{
node: node, node: node,
logger: logger, logger: node.Logger(),
streams: structs.NewMap(), streams: structs.NewMap(),
subs: structs.NewMap(), subs: structs.NewMap(),
} }