@@ -219,17 +219,6 @@ func (s *server) GetTokenAccountInfos(ctx context.Context, req *accountpb.GetTok
219219 filteredRecords = allRecords
220220 }
221221
222- // Trigger a deposit sync with the blockchain for the primary account, if it exists
223- for _ , records := range filteredRecords {
224- if records .General .AccountType == commonpb .AccountType_PRIMARY && ! records .General .RequiresDepositSync {
225- records .General .RequiresDepositSync = true
226- err = s .data .UpdateAccountInfo (ctx , records .General )
227- if err != nil {
228- log .With (zap .Error (err ), zap .String ("token_account" , records .General .TokenAccount )).Warn ("failure marking primary account for deposit sync" )
229- }
230- }
231- }
232-
233222 // Fetch balances
234223 balanceMetadataByTokenAccount , err := s .fetchBalances (ctx , filteredRecords )
235224 if err != nil {
@@ -277,6 +266,23 @@ func (s *server) GetTokenAccountInfos(ctx context.Context, req *accountpb.GetTok
277266 log .With (zap .Error (err )).Warn ("failure adding requesting owner metadata" )
278267 return nil , status .Error (codes .Internal , "" )
279268 }
269+
270+ go func () {
271+ // Trigger a deposit sync with the blockchain for the primary account, if it exists
272+ for _ , records := range filteredRecords {
273+ ctx , cancel := context .WithTimeout (context .Background (), 250 * time .Millisecond )
274+ defer cancel ()
275+
276+ if records .General .AccountType == commonpb .AccountType_PRIMARY && ! records .General .RequiresDepositSync {
277+ records .General .RequiresDepositSync = true
278+ err = s .data .UpdateAccountInfo (ctx , records .General )
279+ if err != nil {
280+ log .With (zap .Error (err ), zap .String ("token_account" , records .General .TokenAccount )).Warn ("failure marking primary account for deposit sync" )
281+ }
282+ }
283+ }
284+ }()
285+
280286 return resp , nil
281287}
282288
0 commit comments