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

Merge branch 'XX-4216/MultiLookup' into 'release'

Add debug for multilookup bindings bug

See merge request !395
parents d240d016 e93a305c
No related branches found
No related tags found
2 merge requests!510Release,!395Add debug for multilookup bindings bug
...@@ -413,9 +413,9 @@ type UdMultiLookupCallback interface { ...@@ -413,9 +413,9 @@ type UdMultiLookupCallback interface {
} }
type lookupResp struct { type lookupResp struct {
id *id.ID Id *id.ID
contact contact.Contact Contact contact.Contact
err error Err error
} }
// MultiLookupUD returns the public key of all passed in IDs as known by the // MultiLookupUD returns the public key of all passed in IDs as known by the
...@@ -458,26 +458,27 @@ func MultiLookupUD(e2eID int, udContact []byte, cb UdMultiLookupCallback, ...@@ -458,26 +458,27 @@ func MultiLookupUD(e2eID int, udContact []byte, cb UdMultiLookupCallback,
return err return err
} }
jww.INFO.Printf("ud.MultiLookupUD(%s, %s)", idList, p.Timeout)
respCh := make(chan lookupResp, len(idList)) respCh := make(chan lookupResp, len(idList))
for _, uid := range idList { for _, uid := range idList {
localID := uid.DeepCopy()
callback := func(c contact.Contact, err error) { callback := func(c contact.Contact, err error) {
respCh <- lookupResp{ respCh <- lookupResp{
id: localID, Id: uid,
contact: c, Contact: c,
err: err, Err: err,
} }
} }
go func() { go func(localID *id.ID) {
_, _, err := ud.Lookup(user.api, c, callback, localID, p) _, _, err := ud.Lookup(user.api, c, callback, localID, p)
if err != nil { if err != nil {
respCh <- lookupResp{ respCh <- lookupResp{
id: localID, Id: localID,
contact: contact.Contact{}, Contact: contact.Contact{},
err: err, Err: err,
} }
} }
}() }(uid.DeepCopy())
} }
...@@ -487,14 +488,14 @@ func MultiLookupUD(e2eID int, udContact []byte, cb UdMultiLookupCallback, ...@@ -487,14 +488,14 @@ func MultiLookupUD(e2eID int, udContact []byte, cb UdMultiLookupCallback,
var errorString string var errorString string
for numReturned := 0; numReturned < len(idList); numReturned++ { for numReturned := 0; numReturned < len(idList); numReturned++ {
response := <-respCh response := <-respCh
if response.err != nil { if response.Err != nil {
failedIDs = append(failedIDs, response.id) failedIDs = append(failedIDs, response.Id)
marshaledContactList = append(
marshaledContactList, response.contact.Marshal())
} else {
errorString = errorString + errorString = errorString +
fmt.Sprintf("Failed to lookup id %s: %+v", fmt.Sprintf("Failed to lookup id %s: %+v",
response.id, response.err) response.Id, response.Err)
} else {
marshaledContactList = append(
marshaledContactList, response.Contact.Marshal())
} }
} }
......
...@@ -44,30 +44,6 @@ func Lookup(user udE2e, ...@@ -44,30 +44,6 @@ func Lookup(user udE2e,
return lookup(net, rng, uid, grp, udContact, callback, p) return lookup(net, rng, uid, grp, udContact, callback, p)
} }
// BatchLookup performs a Lookup operation on a list of user IDs.
// The lookup performs a callback on each lookup on the returned contact object
// constructed from the response.
func BatchLookup(udContact contact.Contact,
net udCmix, callback lookupCallback,
rng csprng.Source,
uids []*id.ID, grp *cyclic.Group,
p single.RequestParams) {
jww.INFO.Printf("ud.BatchLookup(%s, %s)", uids, p.Timeout)
for _, uid := range uids {
go func(localUid *id.ID) {
_, _, err := lookup(net, rng, localUid, grp,
udContact, callback, p)
if err != nil {
jww.WARN.Printf("Failed batch lookup on user %s: %v",
localUid, err)
}
}(uid)
}
return
}
// lookup is a helper function which sends a lookup request to the user discovery // lookup is a helper function which sends a lookup request to the user discovery
// service. It will construct a contact object off of the returned public key. // service. It will construct a contact object off of the returned public key.
// The callback will be called on that contact object. // The callback will be called on that contact object.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment