Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
perf(wallet): limit transaction polling to local wallets
Browse files Browse the repository at this point in the history
  • Loading branch information
mrfelton committed Oct 10, 2020
1 parent c773c33 commit 69ca996
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
15 changes: 10 additions & 5 deletions renderer/components/App/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const PEERS_REFETCH_BACKOFF_SCHEDULE = 2
const appScheduler = createScheduler()

const App = ({
activeWalletSettings,
isAppReady,
modals,
redirectPayReq,
Expand Down Expand Up @@ -67,16 +68,18 @@ const App = ({
maxDelay: PEERS_MAX_REFETCH_INTERVAL,
backoff: PEERS_REFETCH_BACKOFF_SCHEDULE,
})
appScheduler.addTask({
task: () => fetchTransactions(true),
taskId: 'fetchTransactions',
baseDelay: TX_REFETCH_INTERVAL,
})
appScheduler.addTask({
task: updateAutopilotNodeScores,
taskId: 'updateAutopilotNodeScores',
baseDelay: AUTOPILOT_SCORES_REFRESH_INTERVAL,
})
if (activeWalletSettings.type === 'local') {
appScheduler.addTask({
task: () => fetchTransactions(true),
taskId: 'fetchTransactions',
baseDelay: TX_REFETCH_INTERVAL,
})
}

// Set wallet open state.
setIsWalletOpen(true)
Expand All @@ -96,6 +99,7 @@ const App = ({
appScheduler.removeAllTasks()
}
}, [
activeWalletSettings,
initActivityHistory,
isSyncedToGraph,
fetchDescribeNetwork,
Expand Down Expand Up @@ -155,6 +159,7 @@ const App = ({
}

App.propTypes = {
activeWalletSettings: PropTypes.object,
fetchDescribeNetwork: PropTypes.func.isRequired,
fetchPeers: PropTypes.func.isRequired,
fetchSuggestedNodes: PropTypes.func.isRequired,
Expand Down
3 changes: 2 additions & 1 deletion renderer/containers/App/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react'
import { connect } from 'react-redux'
import { fetchPeers } from 'reducers/peers'
import { fetchDescribeNetwork } from 'reducers/network'
import { setIsWalletOpen } from 'reducers/wallet'
import { setIsWalletOpen, walletSelectors } from 'reducers/wallet'
import { updateAutopilotNodeScores } from 'reducers/autopilot'
import { initActivityHistory } from 'reducers/activity'
import { fetchTransactions } from 'reducers/transaction'
Expand All @@ -23,6 +23,7 @@ import ModalStack from './ModalStack'
import AppErrorBoundary from './ErrorBoundary'

const mapStateToProps = state => ({
activeWalletSettings: walletSelectors.activeWalletSettings(state),
isAppReady: appSelectors.isAppReady(state),
isSyncedToGraph: infoSelectors.isSyncedToGraph(),
redirectPayReq: state.pay.redirectPayReq,
Expand Down

0 comments on commit 69ca996

Please sign in to comment.