瀏覽代碼

Batch transactions (#619)

guibescos 2 年之前
父節點
當前提交
20b18e291d
共有 1 個文件被更改,包括 13 次插入9 次删除
  1. 13 9
      governance/xc_admin/packages/xc_admin_common/src/propose.ts

+ 13 - 9
governance/xc_admin/packages/xc_admin_common/src/propose.ts

@@ -20,6 +20,7 @@ import { ExecutePostedVaa } from "./governance_payload/ExecutePostedVaa";
 import { OPS_KEY } from "./multisig";
 
 export const MAX_EXECUTOR_PAYLOAD_SIZE = PACKET_DATA_SIZE - 687; // Bigger payloads won't fit in one addInstruction call when adding to the proposal
+export const SIZE_OF_SIGNED_BATCH = 30;
 
 type SquadInstruction = {
   instruction: TransactionInstruction;
@@ -111,15 +112,18 @@ export async function proposeInstructions(
   ixToSend.push(await squad.buildApproveTransaction(vault, newProposalAddress));
 
   const txToSend = batchIntoTransactions(ixToSend);
-  await new AnchorProvider(
-    squad.connection,
-    squad.wallet,
-    AnchorProvider.defaultOptions()
-  ).sendAll(
-    txToSend.map((tx) => {
-      return { tx, signers: [] };
-    })
-  );
+
+  for (let i = 0; i < txToSend.length; i += SIZE_OF_SIGNED_BATCH) {
+    await new AnchorProvider(
+      squad.connection,
+      squad.wallet,
+      AnchorProvider.defaultOptions()
+    ).sendAll(
+      txToSend.slice(i, i + SIZE_OF_SIGNED_BATCH).map((tx) => {
+        return { tx, signers: [] };
+      })
+    );
+  }
   return newProposalAddress;
 }