Browse Source

fix(sync %): fix the logic around the sync %

renovate/lint-staged-8.x
Jack Mallers 7 years ago
parent
commit
297e87b3d7
  1. 6
      app/main.dev.js
  2. 20
      app/reducers/lnd.js

6
app/main.dev.js

@ -191,16 +191,16 @@ const startLnd = () => {
}
// Pass current clock height progress to front end for loading state UX
if (line.includes('Caught up to height')) {
if (line.includes('Caught up to height') || line.includes('Catching up block hashes to height')) {
// const blockHeight = line.slice(line.indexOf('Caught up to height') + 'Caught up to height'.length).trim()
const blockHeight = line.slice(line.indexOf('Caught up to height') + 'Caught up to height'.length).trim()
mainWindow.webContents.send('lndStdout', blockHeight)
mainWindow.webContents.send('lndStdout', line)
}
// When LND is all caught up to the blockchain
if (line.includes('Chain backend is fully synced')) {
// Log that LND is caught up to the current block height
console.log('NEUTRINO IS SYNCED')
// Check for certs to exists before we do things
// Let the front end know we have stopped syncing LND
syncing = false

20
app/reducers/lnd.js

@ -32,9 +32,23 @@ export const lndSynced = () => (dispatch) => {
}
// Receive IPC event for LND streaming a line
export const lndStdout = (event, lndBlockHeight) => dispatch => (
dispatch({ type: RECEIVE_LINE, lndBlockHeight: lndBlockHeight.split(' ')[0].split(/(\r\n|\n|\r)/gm)[0] })
)
export const lndStdout = (event, line) => dispatch => {
let height
let trimmed
if (line.includes('Caught up to height')) {
trimmed = line.slice(line.indexOf('Caught up to height') + 'Caught up to height'.length).trim()
height = trimmed.split(' ')[0].split(/(\r\n|\n|\r)/gm)[0]
}
if (line.includes('Catching up block hashes to height')) {
trimmed = line.slice(line.indexOf('Catching up block hashes to height') + 'Catching up block hashes to height'.length).trim()
height = trimmed.match(/[-]{0,1}[\d.]*[\d]+/g)[0]
}
dispatch({ type: RECEIVE_LINE, lndBlockHeight: height })
}
export function getBlockHeight() {
return {

Loading…
Cancel
Save