Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions ocp/rpc/account/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,17 +219,6 @@ func (s *server) GetTokenAccountInfos(ctx context.Context, req *accountpb.GetTok
filteredRecords = allRecords
}

// Trigger a deposit sync with the blockchain for the primary account, if it exists
for _, records := range filteredRecords {
if records.General.AccountType == commonpb.AccountType_PRIMARY && !records.General.RequiresDepositSync {
records.General.RequiresDepositSync = true
err = s.data.UpdateAccountInfo(ctx, records.General)
if err != nil {
log.With(zap.Error(err), zap.String("token_account", records.General.TokenAccount)).Warn("failure marking primary account for deposit sync")
}
}
}

// Fetch balances
balanceMetadataByTokenAccount, err := s.fetchBalances(ctx, filteredRecords)
if err != nil {
Expand Down Expand Up @@ -277,6 +266,23 @@ func (s *server) GetTokenAccountInfos(ctx context.Context, req *accountpb.GetTok
log.With(zap.Error(err)).Warn("failure adding requesting owner metadata")
return nil, status.Error(codes.Internal, "")
}

go func() {
// Trigger a deposit sync with the blockchain for the primary account, if it exists
for _, records := range filteredRecords {
ctx, cancel := context.WithTimeout(context.Background(), 250*time.Millisecond)
defer cancel()

if records.General.AccountType == commonpb.AccountType_PRIMARY && !records.General.RequiresDepositSync {
records.General.RequiresDepositSync = true
err = s.data.UpdateAccountInfo(ctx, records.General)
if err != nil {
log.With(zap.Error(err), zap.String("token_account", records.General.TokenAccount)).Warn("failure marking primary account for deposit sync")
}
}
}
}()

return resp, nil
}

Expand Down
Loading