Skip to content
Snippets Groups Projects
Commit 1b43aac9 authored by Josh Brooks's avatar Josh Brooks
Browse files

Fix lazy loading for UD name service

parent 3c910849
No related branches found
No related tags found
4 merge requests!510Release,!419rewrote the health tracker to both consider if there are waiting rounds and...,!367Xx 4150/channel bindings,!340Project/channels
...@@ -25,7 +25,6 @@ const ( ...@@ -25,7 +25,6 @@ const (
graceDuration time.Duration = time.Hour graceDuration time.Duration = time.Hour
) )
var startChannelNameServiceOnce sync.Once
var ErrChannelLeaseSignature = errors.New("failure to validate lease signature") var ErrChannelLeaseSignature = errors.New("failure to validate lease signature")
// loadRegistrationDisk loads a registrationDisk from the kv // loadRegistrationDisk loads a registrationDisk from the kv
...@@ -356,24 +355,26 @@ func (c *clientIDTracker) requestChannelLease() (int64, []byte, error) { ...@@ -356,24 +355,26 @@ func (c *clientIDTracker) requestChannelLease() (int64, []byte, error) {
// StartChannelNameService creates a new clientIDTracker // StartChannelNameService creates a new clientIDTracker
// and returns a reference to it's type as the NameService interface. // and returns a reference to it's type as the NameService interface.
// However it's scheduler thread isn't started until it's Start // However, it's scheduler thread isn't started until it's Start
// method is called. // method is called.
func (m *Manager) StartChannelNameService() channels.NameService { func (m *Manager) StartChannelNameService() (channels.NameService, error) {
if m.nameService == nil {
udPubKeyBytes := m.user.GetCmix().GetInstance().GetPartialNdf().Get().UDB.DhPubKey udPubKeyBytes := m.user.GetCmix().GetInstance().GetPartialNdf().Get().UDB.DhPubKey
var service channels.NameService
username, err := m.store.GetUsername() username, err := m.store.GetUsername()
if err != nil { if err != nil {
jww.FATAL.Panic(err) return nil, err
} }
startChannelNameServiceOnce.Do(func() { m.nameService = newclientIDTracker(
service = newclientIDTracker(
m.comms, m.comms,
m.ud.host, m.ud.host,
username, username,
m.getKv(), m.getKv(),
m.user.GetReceptionIdentity(), m.user.GetReceptionIdentity(),
ed25519.PublicKey(udPubKeyBytes), udPubKeyBytes,
m.getRng()) m.getRng())
})
return service }
return m.nameService, nil
} }
...@@ -37,6 +37,9 @@ type Manager struct { ...@@ -37,6 +37,9 @@ type Manager struct {
// ud is the tracker for the contact information of the specified UD server. // ud is the tracker for the contact information of the specified UD server.
// This information is specified in Manager's constructors (NewOrLoad and NewManagerFromBackup). // This information is specified in Manager's constructors (NewOrLoad and NewManagerFromBackup).
ud *userDiscovery ud *userDiscovery
//
nameService *clientIDTracker
} }
// NewOrLoad loads an existing Manager from storage or creates a // NewOrLoad loads an existing Manager from storage or creates a
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment