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
Branches
Tags
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 (
graceDuration time.Duration = time.Hour
)
var startChannelNameServiceOnce sync.Once
var ErrChannelLeaseSignature = errors.New("failure to validate lease signature")
// loadRegistrationDisk loads a registrationDisk from the kv
......@@ -356,24 +355,26 @@ func (c *clientIDTracker) requestChannelLease() (int64, []byte, error) {
// StartChannelNameService creates a new clientIDTracker
// 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.
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
var service channels.NameService
username, err := m.store.GetUsername()
if err != nil {
jww.FATAL.Panic(err)
return nil, err
}
startChannelNameServiceOnce.Do(func() {
service = newclientIDTracker(
m.nameService = newclientIDTracker(
m.comms,
m.ud.host,
username,
m.getKv(),
m.user.GetReceptionIdentity(),
ed25519.PublicKey(udPubKeyBytes),
udPubKeyBytes,
m.getRng())
})
return service
}
return m.nameService, nil
}
......@@ -37,6 +37,9 @@ type Manager struct {
// ud is the tracker for the contact information of the specified UD server.
// This information is specified in Manager's constructors (NewOrLoad and NewManagerFromBackup).
ud *userDiscovery
//
nameService *clientIDTracker
}
// 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