Sfoglia il codice sorgente

feat(solana_pusher): wait for confirmation only for multiple jito bundles

Guillermo Bescos 1 anno fa
parent
commit
2fa3a39438
1 ha cambiato i file con 20 aggiunte e 17 eliminazioni
  1. 20 17
      apps/price_pusher/src/solana/solana.ts

+ 20 - 17
apps/price_pusher/src/solana/solana.ts

@@ -156,25 +156,28 @@ export class SolanaPricePusherJito implements IPricePusher {
       await this.pythSolanaReceiver.connection.getLatestBlockhashAndContext({
         commitment: "confirmed",
       });
-    await this.pythSolanaReceiver.connection.confirmTransaction(
-      {
-        signature: firstSignature,
-        blockhash: blockhashResult.value.blockhash,
-        lastValidBlockHeight: blockhashResult.value.lastValidBlockHeight,
-      },
-      "confirmed"
-    );
 
-    for (
-      let i = this.jitoBundleSize;
-      i < transactions.length;
-      i += this.jitoBundleSize
-    ) {
-      await sendTransactionsJito(
-        transactions.slice(i, i + this.jitoBundleSize),
-        this.searcherClient,
-        this.pythSolanaReceiver.wallet
+    if (transactions.length > this.jitoBundleSize) {
+      await this.pythSolanaReceiver.connection.confirmTransaction(
+        {
+          signature: firstSignature,
+          blockhash: blockhashResult.value.blockhash,
+          lastValidBlockHeight: blockhashResult.value.lastValidBlockHeight,
+        },
+        "confirmed"
       );
+
+      for (
+        let i = this.jitoBundleSize;
+        i < transactions.length;
+        i += this.jitoBundleSize
+      ) {
+        await sendTransactionsJito(
+          transactions.slice(i, i + this.jitoBundleSize),
+          this.searcherClient,
+          this.pythSolanaReceiver.wallet
+        );
+      }
     }
   }
 }