Skip to content

Commit

Permalink
feat(release): update 692ed15
Browse files Browse the repository at this point in the history
  • Loading branch information
fedellen committed May 22, 2024
1 parent fd14e81 commit 1cd0012
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
30 changes: 30 additions & 0 deletions src/arch/arweaveGateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export interface Gateway {
bundledIn?: TransactionId;
}[]
>;
postBundleTxToAdminQueue(bundleTxId: TransactionId): Promise<void>;
}

export class ArweaveGateway implements Gateway {
Expand Down Expand Up @@ -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<void> {
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",
});
}
}
}
}
7 changes: 4 additions & 3 deletions src/jobs/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1cd0012

Please sign in to comment.