Skip to content
Snippets Groups Projects
Commit 1502b938 authored by Richard T. Carback III's avatar Richard T. Carback III
Browse files

Copy off the contact object for use in the result pointer

parent d444f934
No related branches found
No related tags found
3 merge requests!233Modify restore to call user-defined bindings callback. Add Sent requests to...,!231Revert "Update store to print changes to the partners list",!192Hotfix/improved restore
...@@ -233,20 +233,23 @@ func LookupContact(userID *id.ID, udManager *ud.Manager, ...@@ -233,20 +233,23 @@ func LookupContact(userID *id.ID, udManager *ud.Manager,
var result *contact.Contact var result *contact.Contact
var err error var err error
lookupCB := func(c contact.Contact, myErr error) { lookupCB := func(c contact.Contact, myErr error) {
if myErr != nil { if myErr == nil {
err = myErr
}
newOwnership := make([]byte, len(c.OwnershipProof)) newOwnership := make([]byte, len(c.OwnershipProof))
copy(newOwnership, c.OwnershipProof) copy(newOwnership, c.OwnershipProof)
newFacts, _, _ := fact.UnstringifyFactList(c.Facts.Stringify()) newFacts, _, _ := fact.UnstringifyFactList(
c.Facts.Stringify())
result = &contact.Contact{ result = &contact.Contact{
ID: c.ID.DeepCopy(), ID: c.ID.DeepCopy(),
DhPubKey: c.DhPubKey.DeepCopy(), DhPubKey: c.DhPubKey.DeepCopy(),
OwnershipProof: newOwnership, OwnershipProof: newOwnership,
Facts: newFacts, Facts: newFacts,
} }
} else {
err = myErr
result = nil
}
waiter.Unlock() waiter.Unlock()
extLookupCB(*result, myErr) extLookupCB(c, myErr)
} }
// Take lock once to make sure I will wait // Take lock once to make sure I will wait
waiter.Lock() waiter.Lock()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment