Skip to content
Permalink
Browse files

feat(wallet): apply BOS node scores to lnd autopilot

Fix #2142
  • Loading branch information...
mrfelton committed May 2, 2019
1 parent b748f4a commit 2a132b4a6b17d5eb5822b85e8bfc0df6d8444b2c
Showing with 17 additions and 2 deletions.
  1. +15 −2 renderer/components/App/App.js
  2. +2 −0 renderer/containers/App.js
@@ -9,6 +9,9 @@ import { MainContent } from 'components/UI'
// but we poll a lot more frequently to make UI a little bit more responsive
const TX_REFETCH_INTERVAL = 1000 * 60 * 1

// Refresh autopilot scores every hour.
const AUTOPILOT_SCORES_REFRESH_INTERVAL = 1000 * 60 * 60

// Initial re-fetch after 2 seconds.
const INITIAL_REFETCH_INTERVAL = 2000

@@ -25,6 +28,7 @@ function App({
isAppReady,
modals,
payReq,
updateAutopilotNodeScores,
fetchActivityHistory,
setIsWalletOpen,
fetchPeers,
@@ -53,10 +57,16 @@ function App({
baseDelay: TX_REFETCH_INTERVAL,
})

appScheduler.addTask({
task: updateAutopilotNodeScores,
taskId: 'updateAutopilotNodeScores',
baseDelay: AUTOPILOT_SCORES_REFRESH_INTERVAL,
})

return () => {
appScheduler.removeAllTasks()
}
}, [fetchPeers, fetchTransactions])
}, [fetchPeers, fetchTransactions, updateAutopilotNodeScores])

useEffect(() => {
// Set wallet open state.
@@ -65,7 +75,9 @@ function App({
fetchActivityHistory()
// fetch node info.
fetchPeers()
}, [fetchActivityHistory, fetchPeers, setIsWalletOpen])
// Update autopilot node scores.
updateAutopilotNodeScores()
}, [fetchActivityHistory, fetchPeers, setIsWalletOpen, updateAutopilotNodeScores])

// Open the pay form when a payment link is used.
useEffect(() => {
@@ -97,6 +109,7 @@ App.propTypes = {
payReq: PropTypes.object,
setIsWalletOpen: PropTypes.func.isRequired,
setModals: PropTypes.func.isRequired,
updateAutopilotNodeScores: PropTypes.func.isRequired,
}

export default App
@@ -1,6 +1,7 @@
import { connect } from 'react-redux'
import { fetchPeers } from 'reducers/peers'
import { setIsWalletOpen } from 'reducers/wallet'
import { updateAutopilotNodeScores } from 'reducers/autopilot'
import { fetchActivityHistory } from 'reducers/activity'
import { fetchTransactions } from 'reducers/transaction'
import { appSelectors } from 'reducers/app'
@@ -15,6 +16,7 @@ const mapStateToProps = state => ({

const mapDispatchToProps = {
fetchPeers,
updateAutopilotNodeScores,
fetchActivityHistory,
setIsWalletOpen,
fetchTransactions,

0 comments on commit 2a132b4

Please sign in to comment.
You can’t perform that action at this time.