From 8ac298e07df2972320f77da5ecbc776170f7e31f Mon Sep 17 00:00:00 2001 From: CalDescent Date: Fri, 11 Feb 2022 18:11:00 +0000 Subject: [PATCH] Allow 3 retries for getTransaction() and getAddressTransactions() requests --- .../java/org/qortal/crosschain/Bitcoiny.java | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/qortal/crosschain/Bitcoiny.java b/src/main/java/org/qortal/crosschain/Bitcoiny.java index 2678a08e..f9951aab 100644 --- a/src/main/java/org/qortal/crosschain/Bitcoiny.java +++ b/src/main/java/org/qortal/crosschain/Bitcoiny.java @@ -229,6 +229,25 @@ public abstract class Bitcoiny implements ForeignBlockchain { return transaction.getOutputs(); } + /** + * Returns transactions for passed script + *

+ * @throws ForeignBlockchainException if error occurs + */ + public List getAddressTransactions(byte[] scriptPubKey, boolean includeUnconfirmed) throws ForeignBlockchainException { + int retries = 0; + ForeignBlockchainException e2 = null; + while (retries <= 3) { + try { + return this.blockchain.getAddressTransactions(scriptPubKey, includeUnconfirmed); + } catch (ForeignBlockchainException e) { + e2 = e; + retries++; + } + } + throw(e2); + } + /** * Returns list of transaction hashes pertaining to passed address. *

@@ -263,7 +282,17 @@ public abstract class Bitcoiny implements ForeignBlockchain { * @throws ForeignBlockchainException if error occurs */ public BitcoinyTransaction getTransaction(String txHash) throws ForeignBlockchainException { - return this.blockchain.getTransaction(txHash); + int retries = 0; + ForeignBlockchainException e2 = null; + while (retries <= 3) { + try { + return this.blockchain.getTransaction(txHash); + } catch (ForeignBlockchainException e) { + e2 = e; + retries++; + } + } + throw(e2); } /**