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

Commit

Permalink
perf(wallet): fetch peer node info early
Browse files Browse the repository at this point in the history
  • Loading branch information
mrfelton committed Oct 4, 2020
1 parent 2305ecb commit 90c07df
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions renderer/reducers/peers.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { grpc } from 'workers'
import { mainLog } from '@zap/utils/log'
import createReducer from '@zap/utils/createReducer'
import { updateNodeData } from 'reducers/network'

// ------------------------------------
// Initial State
Expand Down Expand Up @@ -32,6 +34,14 @@ export const fetchPeers = () => async dispatch => {
dispatch({ type: FETCH_PEERS })
try {
const { peers } = await grpc.services.Lightning.listPeers()
peers.forEach(async ({ pubKey }) => {
try {
const { node } = await grpc.services.Lightning.getNodeInfo({ pubKey })
dispatch(updateNodeData([node]))
} catch (error) {
mainLog.warn('Unable to get node info for peer %s: %s', pubKey, error)
}
})
dispatch({ type: FETCH_PEERS_SUCCESS, peers })
} catch (error) {
dispatch({ type: FETCH_PEERS_FAILURE, error })
Expand Down

0 comments on commit 90c07df

Please sign in to comment.