Skip to content
Permalink
Browse files

perf(lnd): run lnd integration in web workers

fix #1990
  • Loading branch information...
mrfelton committed Apr 8, 2019
1 parent 32d7ddc commit 7b83112d048ca16161a6ea58a6cff2f62bbbbcbf
Showing with 2,197 additions and 2,898 deletions.
  1. +41 −392 electron/controller.js
  2. +1 −0 electron/main.js
  3. +30 −1 electron/preload.js
  4. +0 −274 lnd/config.js
  5. +0 −132 lnd/methods/channelController.js
  6. +0 −251 lnd/methods/index.js
  7. +0 −56 lnd/methods/invoicesController.js
  8. +0 −54 lnd/methods/networkController.js
  9. +0 −45 lnd/methods/paymentsController.js
  10. +0 −31 lnd/methods/peersController.js
  11. +0 −97 lnd/methods/walletController.js
  12. +0 −16 lnd/push/closechannel.js
  13. +0 −42 lnd/push/openchannel.js
  14. +0 −69 lnd/push/sendpayment.js
  15. +0 −16 lnd/push/subscribeinvoice.js
  16. +0 −23 lnd/subscribe/channelgraph.js
  17. +0 −18 lnd/subscribe/invoices.js
  18. +0 −18 lnd/subscribe/transactions.js
  19. +0 −38 lnd/walletUnlockerMethods/index.js
  20. +1 −0 package.json
  21. +6 −3 renderer/components/Home/Home.js
  22. +8 −7 renderer/components/Home/WalletLauncher.js
  23. +0 −10 renderer/components/Home/WalletUnlocker.js
  24. +2 −3 renderer/components/Onboarding/Onboarding.js
  25. +10 −10 renderer/components/Syncing/Syncing.js
  26. +4 −4 renderer/containers/Dialog/DialogLndCrashed.js
  27. +4 −2 renderer/containers/Home.js
  28. +7 −4 renderer/containers/Initializer.js
  29. +2 −6 renderer/containers/Logout.js
  30. +0 −3 renderer/containers/Onboarding.js
  31. +6 −6 renderer/containers/Syncing.js
  32. +10 −8 renderer/reducers/address.js
  33. +45 −2 renderer/reducers/app.js
  34. +5 −3 renderer/reducers/balance.js
  35. +56 −61 renderer/reducers/channels.js
  36. +5 −3 renderer/reducers/index.js
  37. +8 −3 renderer/reducers/info.js
  38. +14 −17 renderer/reducers/invoice.js
  39. +5 −124 renderer/reducers/ipc.js
  40. +379 −376 renderer/reducers/lnd.js
  41. +6 −4 renderer/reducers/network.js
  42. +388 −0 renderer/reducers/neutrino.js
  43. +1 −29 renderer/reducers/onboarding.js
  44. +10 −4 renderer/reducers/pay.js
  45. +45 −11 renderer/reducers/payment.js
  46. +8 −114 renderer/reducers/peers.js
  47. +13 −4 renderer/reducers/ticker.js
  48. +26 −16 renderer/reducers/transaction.js
  49. +5 −4 renderer/reducers/utils.js
  50. +49 −0 renderer/workers/index.js
  51. +4 −0 renderer/workers/lightning.worker.js
  52. +4 −0 renderer/workers/neutrino.worker.js
  53. +4 −0 renderer/workers/walletUnlocker.worker.js
  54. +1 −0 services/bitcoind/index.js
  55. +45 −22 lnd/walletUnlocker.js → services/grpc/grpcService.js
  56. +3 −0 services/grpc/lightning/index.js
  57. +39 −106 {lnd → services/grpc/lightning}/lightning.js
  58. +471 −0 services/grpc/lightning/lightning.methods.js
  59. +77 −0 services/grpc/lightning/lightning.subscriptions.js
  60. +3 −0 services/grpc/walletUnlocker/index.js
  61. +17 −0 services/grpc/walletUnlocker/walletUnlocker.js
  62. +49 −0 services/grpc/walletUnlocker/walletUnlocker.methods.js
  63. +16 −0 services/neutrino/index.js
  64. +85 −62 {lnd → services/neutrino}/neutrino.js
  65. +0 −4 stories/containers/home.stories.js
  66. +0 −1 stories/containers/onboarding.stories.js
  67. +4 −4 stories/containers/syncing.stories.js
  68. +16 −8 test/unit/lnd/lnd-config.spec.js
  69. +53 −41 test/unit/lnd/neutrino.spec.js
  70. +0 −142 test/unit/reducers/__snapshots__/peers.spec.js.snap
  71. +1 −76 test/unit/reducers/peers.spec.js
  72. +16 −16 utils/lndConfig.js
  73. +41 −0 webpack/dev/workers.config.js
  74. +39 −0 webpack/prod/workers.config.js
  75. +2 −1 webpack/webpack.config.dev.js
  76. +2 −1 webpack/webpack.config.prod.js
  77. +5 −0 yarn.lock

Large diffs are not rendered by default.

@@ -244,6 +244,7 @@ app.on('ready', async () => {
backgroundColor: get(theme, 'colors.primaryColor', '#242633'),
webPreferences: {
nodeIntegration: false,
nodeIntegrationInWorker: true,
preload: isDev
? path.resolve(__dirname, '..', 'dist', 'preload.js')
: path.resolve(__dirname, 'preload.js'),
@@ -14,8 +14,11 @@ import config from 'config'
import { getDb } from '@zap/renderer/store/db'
import isSubDir from '@zap/utils/isSubDir'
import { getAllLocalWallets } from '@zap/utils/localWallets'
import lndBinaryPath from '@zap/utils/lndBinaryPath'
import lndGrpcProtoPath from '@zap/utils/lndGrpcProtoPath'
import validateHost from '@zap/utils/validateHost'
import { getDbName } from '@zap/utils/db'
import LndConfig from '@zap/utils/lndConfig'

const fsReadFile = promisify(fs.readFile)
const fsRimraf = promisify(rimraf)
@@ -68,10 +71,35 @@ function openTestnetFaucet() {
function killLnd() {
return new Promise(resolve => {
ipcRenderer.once('killLndSuccess', resolve)
ipcRenderer.send('killLnd', { signal: 'SIGKILL', timeout: 2500 })
ipcRenderer.send('killLnd')
})
}

/**
* Generates an lnd config object from a wallet config.
* @param {Object} wallet Wallet config
* @return {Object} Lnd config
*/
async function generateLndConfigFromWallet(wallet) {
// Convert wallet config to lnd config.
wallet.decoder = wallet.decoder || 'lnd.lndconnect.v1'
let lndConfig = new LndConfig({
...wallet,
userDataDir: getUserDataDir(),
binaryPath: lndBinaryPath(),
protoPath: lndGrpcProtoPath(),
})

// Wait for the config to become fully initialized.
await lndConfig.isReady

// Flatten the config into a plan object so we can pass it between services.
// We can not pass a Promise to the Web Worker, so replace with true value.
lndConfig = Object.assign({}, lndConfig, { isReady: true })

return lndConfig
}

/**
* Returns specified wallet files location
* @param {*} chain
@@ -158,6 +186,7 @@ window.Zap = {
openExternal,
openHelpPage,
openTestnetFaucet,
generateLndConfigFromWallet,
getWalletDir,
getAllLocalWallets,
deleteLocalWallet,

This file was deleted.

0 comments on commit 7b83112

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