Skip to content

Commit

Permalink
feat: remove confirmation caching
Browse files Browse the repository at this point in the history
  • Loading branch information
Polybius93 committed Sep 23, 2024
1 parent b6e1588 commit 884a31f
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions src/app/hooks/use-confirmation-checker.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useContext, useRef } from 'react';
import { useContext } from 'react';

import { Vault } from '@models/vault';
import { VaultContext } from '@providers/vault-context-provider';
Expand All @@ -10,7 +10,6 @@ export function useConfirmationChecker(): [string, number][] {
const blockHeight = useBlockchainHeightQuery();
const { pendingVaults } = useContext(VaultContext);

const bitcoinTransactionBlockHeightMap = useRef(new Map<string, number>());

async function fetchBitcoinTransactionBlockHeight(vault: Vault): Promise<number> {
try {
Expand All @@ -23,11 +22,6 @@ export function useConfirmationChecker(): [string, number][] {
if (!bitcoinTransactionBlockHeight)
throw new Error('Could not fetch Bitcoin Transaction Block Height');

bitcoinTransactionBlockHeightMap.current.set(
vault.withdrawDepositTX,
bitcoinTransactionBlockHeight
);

return bitcoinTransactionBlockHeight;
} catch (error) {
throw new Error('Error fetching Bitcoin Transaction Block Height');
Expand All @@ -40,8 +34,7 @@ export function useConfirmationChecker(): [string, number][] {
): Promise<number> {
try {
const bitcoinTransactionBlockHeight =
bitcoinTransactionBlockHeightMap.current.get(vault.withdrawDepositTX) ??
(await fetchBitcoinTransactionBlockHeight(vault));
await fetchBitcoinTransactionBlockHeight(vault);

return blockHeight - bitcoinTransactionBlockHeight;
} catch (error) {
Expand Down

0 comments on commit 884a31f

Please sign in to comment.