diff --git a/ud/lookup.go b/ud/lookup.go index 867c2900cbf598be9e041f1de1244a9379e0c919..569dc5b99578e9487c350028eb5e4649cbf8efc1 100644 --- a/ud/lookup.go +++ b/ud/lookup.go @@ -44,6 +44,30 @@ func Lookup(user udE2e, 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 // service. It will construct a contact object off of the returned public key. // The callback will be called on that contact object.