diff --git a/ud/channelIDTracking.go b/ud/channelIDTracking.go index ee1938ec3fe959eed6c788014e8b820362f0211d..3eb25a4a3fa4d3d0721d119c3c260667e44b4e25 100644 --- a/ud/channelIDTracking.go +++ b/ud/channelIDTracking.go @@ -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 { - 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) - } - startChannelNameServiceOnce.Do(func() { - service = newclientIDTracker( +func (m *Manager) StartChannelNameService() (channels.NameService, error) { + + if m.nameService == nil { + udPubKeyBytes := m.user.GetCmix().GetInstance().GetPartialNdf().Get().UDB.DhPubKey + username, err := m.store.GetUsername() + if err != nil { + return nil, err + } + 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 } diff --git a/ud/manager.go b/ud/manager.go index d431da78c9f961ac7112923203eb54f51dae9564..010b7d5aa079b622b53fa374d75f6474c975d08b 100644 --- a/ud/manager.go +++ b/ud/manager.go @@ -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