@@ -195,17 +195,21 @@ async def __aexit__(self, exc_type: Any, exc_value: Any, traceback: Any):
195195 await self .close ()
196196
197197 async def update_accounts (self , accounts : Sequence [SolanaAccount ]) -> None :
198- resp = await self .get_account_info ([account .key for account in accounts ])
199- slot = resp ["context" ]["slot" ]
200- values = resp ["value" ]
201- for account , value in zip (accounts , values ):
202- if value is None :
203- logger .warning ("got null value from Solana getMultipleAccounts for {}; non-existent account?" , account .key )
204- continue
205- try :
206- account .update_with_rpc_response (slot , value )
207- except Exception as ex :
208- logger .exception ("error while updating account {}" , account .key , exception = ex )
198+ # Solana's getMultipleAccounts RPC is limited to 100 accounts
199+ # Hence we have to split them into groups of 100
200+ # https://docs.solana.com/developing/clients/jsonrpc-api#getmultipleaccounts
201+ for grouped_accounts in [accounts [i :i + 100 ] for i in range (0 , len (accounts ), 100 )]:
202+ resp = await self .get_account_info ([account .key for account in grouped_accounts ])
203+ slot = resp ["context" ]["slot" ]
204+ values = resp ["value" ]
205+ for account , value in zip (grouped_accounts , values ):
206+ if value is None :
207+ logger .warning ("got null value from Solana getMultipleAccounts for {}; non-existent account?" , account .key )
208+ continue
209+ try :
210+ account .update_with_rpc_response (slot , value )
211+ except Exception as ex :
212+ logger .exception ("error while updating account {}" , account .key , exception = ex )
209213
210214 async def http_send (self , method : str , params : Optional [List [Any ]] = None , * , return_error : bool = False ) -> Any :
211215 if self .ratelimit :
0 commit comments