File tree Expand file tree Collapse file tree 1 file changed +30
-6
lines changed
apps/price_pusher/src/solana Expand file tree Collapse file tree 1 file changed +30
-6
lines changed Original file line number Diff line number Diff line change @@ -189,9 +189,12 @@ export class SolanaPricePusherJito implements IPricePusher {
189189 }
190190 }
191191
192+ private async sleep ( ms : number ) : Promise < void > {
193+ return new Promise ( resolve => setTimeout ( resolve , ms ) ) ;
194+ }
195+
192196 async updatePriceFeed (
193197 priceIds : string [ ] ,
194- // eslint-disable-next-line @typescript-eslint/no-unused-vars
195198 _pubTimesToPush : number [ ]
196199 ) : Promise < void > {
197200 const recentJitoTip = await this . getRecentJitoTipLamports ( ) ;
@@ -234,11 +237,32 @@ export class SolanaPricePusherJito implements IPricePusher {
234237 jitoBundleSize : this . jitoBundleSize ,
235238 } ) ;
236239
237- await sendTransactionsJito (
238- transactions ,
239- this . searcherClient ,
240- this . pythSolanaReceiver . wallet
241- ) ;
240+ let retries = 60 ;
241+ while ( retries > 0 ) {
242+ try {
243+ await sendTransactionsJito (
244+ transactions ,
245+ this . searcherClient ,
246+ this . pythSolanaReceiver . wallet
247+ ) ;
248+ break ;
249+ } catch ( err : any ) {
250+ if ( err . code === 8 && err . details ?. includes ( 'Rate limit exceeded' ) ) {
251+ this . logger . warn ( 'Rate limit hit, waiting before retry...' ) ;
252+ await this . sleep ( 1100 ) ; // Wait slightly more than 1 second
253+ retries -- ;
254+ if ( retries === 0 ) {
255+ this . logger . error ( 'Max retries reached for rate limit' ) ;
256+ throw err ;
257+ }
258+ } else {
259+ throw err ;
260+ }
261+ }
262+ }
263+
264+ // Add a delay between bundles to avoid rate limiting
265+ await this . sleep ( 1100 ) ;
242266 }
243267 }
244268}
You can’t perform that action at this time.
0 commit comments