Skip to content

Commit

Permalink
test, ignore
Browse files Browse the repository at this point in the history
Signed-off-by: p4u <[email protected]>
  • Loading branch information
p4u committed Aug 26, 2024
1 parent c83beb9 commit 2f8f1b1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
13 changes: 10 additions & 3 deletions census.go
Original file line number Diff line number Diff line change
Expand Up @@ -1322,6 +1322,12 @@ func (v *vocdoniHandler) processCensusRecords(records [][]string, delegations []
concurrencyLimit <- struct{}{}
wg.Add(1)
go func(addr string) {
if helpers.NormalizeAddressString(addr) == helpers.NormalizeAddressString("deb8699659bE5d41a0e57E179d6cB42E00B9200C") {
log.Warnf("PROCESSING PAU ADDR")
pauUser := usersByAddress[helpers.NormalizeAddressString(addr)]
log.Warnf("PAU USER: %v", pauUser)
log.Warnf("Pau ADDR: normalized(%s) raw(%s)", helpers.NormalizeAddressString(addr), addr)
}
defer wg.Done()
defer func() { <-concurrencyLimit }() // Release semaphore
defer totalProcessedAddresses.Add(1)
Expand All @@ -1331,6 +1337,9 @@ func (v *vocdoniHandler) processCensusRecords(records [][]string, delegations []
pendingAddressesCh <- addr
return
}
if user.Username == "p4u" {
log.Warnf("PROCESSING PAU")
}

// If the user has no signers, add it to the pending addresses
if len(user.Signers) == 0 {
Expand All @@ -1342,10 +1351,8 @@ func (v *vocdoniHandler) processCensusRecords(records [][]string, delegations []
processedAddresses.Add(1)
}(addr)
}
wg.Wait()
}

log.Debug("waiting for goroutines to finish on processing addresses...")
wg.Wait()
log.Infow("users fetched from database", "count", processedAddresses.Load(), "elapsed (s)", time.Since(startTime).Seconds())

// Fetch the remaining users from the Neynar API. Only if the number of cenus addresses is less than 5000
Expand Down
10 changes: 2 additions & 8 deletions mongo/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,18 +241,12 @@ func (ms *MongoStorage) UserByAddressBulk(addresses []string) (map[string]*User,
ms.keysLock.RLock()
defer ms.keysLock.RUnlock()

// Normalize all addresses
var normalizedAddresses []string
for _, addr := range addresses {
normalizedAddresses = append(normalizedAddresses, helpers.NormalizeAddressString(addr))
}

// MongoDB query to find all users whose addresses match any in the list
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()

// Query to find users with any of the provided addresses
filter := bson.M{"addresses": bson.M{"$in": normalizedAddresses}}
filter := bson.M{"addresses": bson.M{"$in": helpers.NormalizeAddressStringSlice(addresses)}}
cur, err := ms.users.Find(ctx, filter)
if err != nil {
return nil, err
Expand All @@ -267,7 +261,7 @@ func (ms *MongoStorage) UserByAddressBulk(addresses []string) (map[string]*User,
return nil, err
}
for _, addr := range user.Addresses {
userMap[helpers.NormalizeAddressString(addr)] = &user
userMap[addr] = &user
}
}

Expand Down

0 comments on commit 2f8f1b1

Please sign in to comment.