-
Notifications
You must be signed in to change notification settings - Fork 295
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DDW-329] Show block replay progress (#2110)
* [DDW-329] Show block replay progress - INIT * [DDW-329] Run Translations Manager * [DDW-329] Fix flow issues and code cleanuo * [DDW-329] Fix flow issues and code cleanup * [DDW-329] CHANGELOG update * [DDW-329] Fix logs path * [DDW-329] Merges develop and fixes CHANGELOG * [DDW-329] Coden cleanup and improvements * [DDW-329] CHANGELOG - PR number update Co-authored-by: Nikola Glumac <niglumac@gmail.com>
- Loading branch information
1 parent
5121774
commit aba9f98
Showing
15 changed files
with
163 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// @flow | ||
import { MainIpcChannel } from './lib/MainIpcChannel'; | ||
import { GET_BLOCK_REPLAY_STATUS_CHANNEL } from '../../common/ipc/api'; | ||
import type { | ||
GetBlockReplayProgressRendererRequest, | ||
GetBlockReplayProgressMainResponse, | ||
} from '../../common/ipc/api'; | ||
|
||
// IpcChannel<Incoming, Outgoing> | ||
|
||
export const getBlockReplayProgressChannel: MainIpcChannel< | ||
GetBlockReplayProgressRendererRequest, | ||
GetBlockReplayProgressMainResponse | ||
> = new MainIpcChannel(GET_BLOCK_REPLAY_STATUS_CHANNEL); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// @flow | ||
import { BrowserWindow } from 'electron'; | ||
import fs from 'fs'; | ||
import readline from 'readline'; | ||
import path from 'path'; | ||
import { getBlockReplayProgressChannel } from '../ipc/get-block-replay-progress'; | ||
import { BLOCK_REPLAY_PROGRESS_CHECK_INTERVAL } from '../config'; | ||
|
||
export const handleCheckBlockReplayProgress = ( | ||
mainWindow: BrowserWindow, | ||
logsDirectoryPath: string | ||
) => { | ||
const checkBlockReplayProgress = async () => { | ||
const filename = 'node.log'; | ||
const logFilePath = `${logsDirectoryPath}/pub/`; | ||
const filePath = path.join(logFilePath, filename); | ||
if (!fs.existsSync(filePath)) return; | ||
|
||
const fileStream = fs.createReadStream(filePath); | ||
const rl = readline.createInterface({ input: fileStream }); | ||
const progress = []; | ||
for await (const line of rl) { | ||
if (line.includes('block replay')) { | ||
progress.push(line); | ||
} | ||
} | ||
if (!progress.length) return; | ||
|
||
const finalProgress = progress.slice(-1).pop(); | ||
const percentage = finalProgress.split('block replay progress (%) =').pop(); | ||
const finalProgressPercentage = parseFloat(percentage); | ||
|
||
// Send result to renderer process (NetworkStatusStore) | ||
getBlockReplayProgressChannel.send( | ||
finalProgressPercentage, | ||
mainWindow.webContents | ||
); | ||
}; | ||
|
||
const setBlockReplayProgressCheckingInterval = () => { | ||
setInterval(async () => { | ||
checkBlockReplayProgress(); | ||
}, BLOCK_REPLAY_PROGRESS_CHECK_INTERVAL); | ||
}; | ||
|
||
// Start default interval | ||
setBlockReplayProgressCheckingInterval(); | ||
|
||
return checkBlockReplayProgress; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// @flow | ||
import { GET_BLOCK_REPLAY_STATUS_CHANNEL } from '../../../common/ipc/api'; | ||
import type { | ||
GetBlockReplayProgressRendererRequest, | ||
GetBlockReplayProgressMainResponse, | ||
} from '../../../common/ipc/api'; | ||
import { RendererIpcChannel } from './lib/RendererIpcChannel'; | ||
|
||
export const getBlockReplayProgressChannel: // IpcChannel<Incoming, Outgoing> | ||
RendererIpcChannel< | ||
GetBlockReplayProgressMainResponse, | ||
GetBlockReplayProgressRendererRequest | ||
> = new RendererIpcChannel(GET_BLOCK_REPLAY_STATUS_CHANNEL); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters