From 1cd00127e6d1e696ac11b89e9ac201c51323df65 Mon Sep 17 00:00:00 2001 From: Derek Sonnenberg Date: Wed, 22 May 2024 11:57:28 -0500 Subject: [PATCH] feat(release): update 692ed15 --- src/arch/arweaveGateway.ts | 30 ++++++++++++++++++++++++++++++ src/jobs/post.ts | 7 ++++--- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/arch/arweaveGateway.ts b/src/arch/arweaveGateway.ts index ecbde9f..08cfaf5 100644 --- a/src/arch/arweaveGateway.ts +++ b/src/arch/arweaveGateway.ts @@ -69,6 +69,7 @@ export interface Gateway { bundledIn?: TransactionId; }[] >; + postBundleTxToAdminQueue(bundleTxId: TransactionId): Promise; } export class ArweaveGateway implements Gateway { @@ -382,4 +383,33 @@ export class ArweaveGateway implements Gateway { ); return new Winston(res.data); } + + /** Optionally posts a prepared bundle to the ar.io gateway's priority bundle queue if an admin key exists */ + public async postBundleTxToAdminQueue( + bundleTxId: TransactionId + ): Promise { + if (process.env.AR_IO_ADMIN_KEY !== undefined) { + logger.debug("Posting bundle to admin queue...", { bundleTxId }); + try { + await this.retryStrategy.sendRequest(() => + this.axiosInstance.post( + `${this.endpoint.href}ar-io/admin/queue-bundle`, + { + id: bundleTxId, + }, + { + headers: { + Authorization: `Bearer ${process.env.AR_IO_ADMIN_KEY}`, + }, + } + ) + ); + } catch (error) { + logger.error("Error posting bundle to admin queue", { + bundleTxId, + error: error instanceof Error ? error.message : "Unknown error", + }); + } + } + } } diff --git a/src/jobs/post.ts b/src/jobs/post.ts index 22168bd..73a1e92 100644 --- a/src/jobs/post.ts +++ b/src/jobs/post.ts @@ -65,9 +65,10 @@ export async function postBundleHandler( try { // post bundle, throw error on failure - const transactionPostResponseData = await arweaveGateway.postBundleTx( - bundleTx - ); + const [transactionPostResponseData] = await Promise.all([ + arweaveGateway.postBundleTx(bundleTx), + arweaveGateway.postBundleTxToAdminQueue(bundleTx.id), + ]); // fetch AR rate - but don't throw on failure const usdToArRate = await paymentService