From 9804eccbf0aa1b5051afdf2e18d7b0554f931a71 Mon Sep 17 00:00:00 2001 From: CalDescent Date: Tue, 8 Feb 2022 18:26:15 +0000 Subject: [PATCH] Removed transaction caching. Can be reintroduced later. --- .../java/org/qortal/crosschain/Bitcoiny.java | 24 +------------------ 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/src/main/java/org/qortal/crosschain/Bitcoiny.java b/src/main/java/org/qortal/crosschain/Bitcoiny.java index 2678a08e..bf5bd230 100644 --- a/src/main/java/org/qortal/crosschain/Bitcoiny.java +++ b/src/main/java/org/qortal/crosschain/Bitcoiny.java @@ -33,7 +33,6 @@ import org.qortal.utils.Amounts; import org.qortal.utils.BitTwiddling; import com.google.common.hash.HashCode; -import org.qortal.utils.NTP; /** Bitcoin-like (Bitcoin, Litecoin, etc.) support */ public abstract class Bitcoiny implements ForeignBlockchain { @@ -48,12 +47,6 @@ public abstract class Bitcoiny implements ForeignBlockchain { protected final NetworkParameters params; - /** Cache recent transactions to speed up subsequent lookups */ - protected List transactionsCache; - protected Long transactionsCacheTimestamp; - protected String transactionsCacheXpub; - protected static long TRANSACTIONS_CACHE_TIMEOUT = 2 * 60 * 1000L; // 2 minutes - /** Keys that have been previously marked as fully spent,
* i.e. keys with transactions but with no unspent outputs. */ protected final Set spentKeys = Collections.synchronizedSet(new HashSet<>()); @@ -350,17 +343,6 @@ public abstract class Bitcoiny implements ForeignBlockchain { public List getWalletTransactions(String key58) throws ForeignBlockchainException { synchronized (this) { - // Serve from the cache if it's recent, and matches this xpub - if (Objects.equals(transactionsCacheXpub, key58)) { - if (transactionsCache != null && transactionsCacheTimestamp != null) { - Long now = NTP.getTime(); - boolean isCacheStale = (now != null && now - transactionsCacheTimestamp >= TRANSACTIONS_CACHE_TIMEOUT); - if (!isCacheStale) { - return transactionsCache; - } - } - } - Context.propagate(bitcoinjContext); Wallet wallet = walletFromDeterministicKey58(key58); @@ -423,13 +405,9 @@ public abstract class Bitcoiny implements ForeignBlockchain { Comparator newestTimestampFirstComparator = Comparator.comparingInt(SimpleTransaction::getTimestamp).reversed(); // Update cache and return - transactionsCacheTimestamp = NTP.getTime(); - transactionsCacheXpub = key58; - transactionsCache = walletTransactions.stream() + return walletTransactions.stream() .map(t -> convertToSimpleTransaction(t, keySet)) .sorted(newestTimestampFirstComparator).collect(Collectors.toList()); - - return transactionsCache; } }