diff --git a/bindings/ud.go b/bindings/ud.go index d5f89cc94510adfda384a2fe7b75c3b7b47c1569..bc4a11ce7be6b98c4a0e7c3df162c024ced0954f 100644 --- a/bindings/ud.go +++ b/bindings/ud.go @@ -226,12 +226,7 @@ func (ud *UserDiscovery) GetFacts() []byte { // GetContact returns the marshalled bytes of the contact.Contact for UD as // retrieved from the NDF. func (ud *UserDiscovery) GetContact() ([]byte, error) { - c, err := ud.api.GetContact() - if err != nil { - return nil, err - } - - return c.Marshal(), nil + return ud.api.GetContact().Marshal(), nil } // ConfirmFact confirms a fact first registered via AddFact. The confirmation ID diff --git a/cmd/ud.go b/cmd/ud.go index 05de64802aa0497d9814e452546601d3ada12912..73a47f02d60e32f588fa1e0f24395a082c23d689 100644 --- a/cmd/ud.go +++ b/cmd/ud.go @@ -124,11 +124,7 @@ var udCmd = &cobra.Command{ jww.INFO.Printf("[UD] Confirmed %v", confirmID) } - udContact, err := userDiscoveryMgr.GetContact() - if err != nil { - fmt.Printf("Failed to get user discovery contact object: %+v", err) - jww.FATAL.Printf("Failed to get user discovery contact object: %+v", err) - } + udContact := userDiscoveryMgr.GetContact() // Handle lookup (verification) process // Note: Cryptographic verification occurs above the bindings layer diff --git a/ud/lookup_test.go b/ud/lookup_test.go index de7fd3f3d488bf5867d9df84a16e18ca897deea9..2b168e4a30c3b04e9840225c43b5e1aab039759c 100644 --- a/ud/lookup_test.go +++ b/ud/lookup_test.go @@ -37,11 +37,6 @@ func TestManager_Lookup(t *testing.T) { // Set up mock manager m, tnm := newTestManager(t) - udContact, err := m.GetContact() - if err != nil { - t.Fatalf("Failed to get contact: %v", err) - } - uid := id.NewIdFromUInt(0x500000000000000, id.User, t) expectedContact := contact.Contact{ ID: uid, @@ -87,7 +82,7 @@ func TestManager_Lookup(t *testing.T) { } // Run the lookup - _, _, err = Lookup(m.user, udContact, callback, uid, p) + _, _, err = Lookup(m.user, m.GetContact(), callback, uid, p) if err != nil { t.Errorf("Lookup() returned an error: %+v", err) } diff --git a/ud/manager.go b/ud/manager.go index d2f0a54f2b68e5731f19a1f95cb75c3dd6a9f3be..0a4247fb809d876b4c0659639827bc2929ba3b83 100644 --- a/ud/manager.go +++ b/ud/manager.go @@ -35,7 +35,7 @@ type Manager struct { factMux sync.Mutex // ud is the tracker for the contact information of the specified UD server. - // This information is specified in NewOrLoad. + // This information is specified in Manager's constructors (NewOrLoad and NewManagerFromBackup). ud *userDiscovery } @@ -193,8 +193,8 @@ func (m *Manager) GetStringifiedFacts() []string { } // GetContact returns the contact.Contact for UD. -func (m *Manager) GetContact() (contact.Contact, error) { - return m.ud.contact, nil +func (m *Manager) GetContact() contact.Contact { + return m.ud.contact } // loadOrNewManager is a helper function which loads from storage or diff --git a/ud/search_test.go b/ud/search_test.go index 865f09d1ecc7e27e1ebbe6aade79e82858b21562..3130e4f9b524a0cd79360a1bbcd42c4430052e8d 100644 --- a/ud/search_test.go +++ b/ud/search_test.go @@ -47,10 +47,8 @@ func TestManager_Search(t *testing.T) { grp = getGroup() var contacts []*Contact - udContact, err := m.GetContact() - if err != nil { - t.Fatalf("Failed to get ud contact: %v", err) - } + udContact := m.GetContact() + contacts = append(contacts, &Contact{ UserID: udContact.ID.Bytes(), PubKey: udContact.DhPubKey.Bytes(), diff --git a/xxmutils/restoreContacts.go b/xxmutils/restoreContacts.go index d7b842725c718a8f5f9fd5abb5cee6f5c48e0989..9f43d294e35b7f6d601ba780b93b69bb0966a002 100644 --- a/xxmutils/restoreContacts.go +++ b/xxmutils/restoreContacts.go @@ -42,11 +42,6 @@ func RestoreContactsFromBackup(backupPartnerIDs []byte, user *xxdk.E2e, updatesCb interfaces.RestoreContactsUpdater) ([]*id.ID, []*id.ID, []error, error) { - udContact, err := udManager.GetContact() - if err != nil { - return nil, nil, nil, err - } - var restored, failed []*id.ID var errs []error @@ -99,7 +94,7 @@ func RestoreContactsFromBackup(backupPartnerIDs []byte, user *xxdk.E2e, rsWg := &sync.WaitGroup{} rsWg.Add(numRoutines) for i := 0; i < numRoutines; i++ { - go LookupContacts(lookupCh, foundCh, failCh, user, udContact, lcWg) + go LookupContacts(lookupCh, foundCh, failCh, user, udManager.GetContact(), lcWg) go ResetSessions(resetContactCh, restoredCh, failCh, user, rsWg) } @@ -131,6 +126,7 @@ func RestoreContactsFromBackup(backupPartnerIDs []byte, user *xxdk.E2e, // Event Processing done := false + var err error for !done { // NOTE: Timer is reset every loop timeoutTimer := time.NewTimer(restoreTimeout)