Browse Source

feature(connect peer error): hook up global error handling for connecting to a peer

renovate/lint-staged-8.x
Jack Mallers 7 years ago
parent
commit
ed11aaa460
  1. 5
      app/lnd/methods/index.js
  2. 3
      app/reducers/ipc.js
  3. 1
      app/reducers/payment.js
  4. 13
      app/reducers/peers.js
  5. 1
      app/reducers/transaction.js

5
app/lnd/methods/index.js

@ -155,7 +155,10 @@ export default function (lnd, event, msg, data) {
console.log('peer_id: ', peer_id)
event.sender.send('connectSuccess', { pub_key: data.pubkey, address: data.host, peer_id })
})
.catch(error => console.log('connectPeer error: ', error))
.catch(error => {
event.sender.send('connectFailure', { error: error.toString() })
console.log('connectPeer error: ', error)
})
break
case 'disconnectPeer':
// Empty response. Pass back pubkey on success to remove it from the peers list

3
app/reducers/ipc.js

@ -3,7 +3,7 @@ import { lndSyncing, lndSynced, lndStdout } from './lnd'
import { receiveInfo } from './info'
import { receiveAddress } from './address'
import { receiveCryptocurrency } from './ticker'
import { receivePeers, connectSuccess, disconnectSuccess } from './peers'
import { receivePeers, connectSuccess, disconnectSuccess, connectFailure } from './peers'
import {
receiveChannels,
@ -69,6 +69,7 @@ const ipc = createIpc({
pushclosechannelstatus,
connectSuccess,
connectFailure,
disconnectSuccess,
receiveAddress,

1
app/reducers/payment.js

@ -84,7 +84,6 @@ export const paymentSuccessful = () => (dispatch) => {
export const paymentFailed = (event, { error }) => (dispatch) => {
dispatch({ type: PAYMENT_FAILED })
console.log('error: ', error)
dispatch(setError(error))
}

13
app/reducers/peers.js

@ -1,5 +1,6 @@
import { createSelector } from 'reselect'
import { ipcRenderer } from 'electron'
import { setError } from './error'
// ------------------------------------
// Constants
// ------------------------------------
@ -27,12 +28,6 @@ export function connectPeer() {
}
}
export function connectFailure() {
return {
type: CONNECT_FAILURE
}
}
export function disconnectPeer() {
return {
type: DISCONNECT_PEER
@ -83,6 +78,12 @@ export const connectRequest = ({ pubkey, host }) => (dispatch) => {
// Send IPC receive for successfully connecting to a peer
export const connectSuccess = (event, peer) => dispatch => dispatch({ type: CONNECT_SUCCESS, peer })
// Send IPC receive for unsuccessfully connecting to a peer
export const connectFailure = (event, { error }) => dispatch => {
dispatch({ type: CONNECT_FAILURE })
dispatch(setError(error))
}
// Send IPC send for disconnecting from a peer
export const disconnectRequest = ({ pubkey }) => (dispatch) => {
dispatch(disconnectPeer())

1
app/reducers/transaction.js

@ -70,7 +70,6 @@ export const transactionSuccessful = (event, { amount, addr, txid }) => (dispatc
export const transactionError = (event, { error }) => (dispatch) => {
dispatch({ type: TRANSACTION_FAILED })
console.log('error: ', error)
dispatch(setError(error))
}

Loading…
Cancel
Save