Skip to content

Commit

Permalink
fix(wallet-core): fasten fast chains
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasklim committed Jul 15, 2024
1 parent 5dcf426 commit ba6e397
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions suite-common/wallet-core/src/blockchain/blockchainThunks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,16 @@ import { fetchAndUpdateAccountThunk } from '../accounts/accountsThunks';
import { BLOCKCHAIN_MODULE_PREFIX, blockchainActions } from './blockchainActions';
import { selectBlockchainState, selectNetworkBlockchainInfo } from './blockchainReducer';

const ACCOUNTS_SYNC_INTERVAL = 60 * 1000;
const DEFAULT_ACCOUNT_SYNC_INTERVAL = 60 * 1000;

// using fast and cheap blockchains, it looks suspicious when tx is not almost instantly confirmed
const CUSTOM_ACCOUNT_SYNC_INTERVALS: Partial<Record<NetworkSymbol, number>> = {
matic: 20 * 1000,
bsc: 20 * 1000,
};

const getAccountSyncInterval = (symbol: NetworkSymbol) =>
CUSTOM_ACCOUNT_SYNC_INTERVALS[symbol] || DEFAULT_ACCOUNT_SYNC_INTERVAL;

// Conditionally subscribe to blockchain backend
// called after TrezorConnect.init successfully emits TRANSPORT.START event
Expand Down Expand Up @@ -329,7 +338,7 @@ export const syncAccountsWithBlockchainThunk = createThunk(
tryClearTimeout(blockchainInfo.syncTimeout);
const timeout = setTimeout(
() => dispatch(syncAccountsWithBlockchainThunk(symbol)),
ACCOUNTS_SYNC_INTERVAL,
getAccountSyncInterval(symbol),
);

dispatch(blockchainActions.synced({ symbol, timeout }));
Expand Down

0 comments on commit ba6e397

Please sign in to comment.