Skip to content

Commit

Permalink
pool status checker
Browse files Browse the repository at this point in the history
  • Loading branch information
Robin-Sch committed Jan 18, 2022
1 parent 29d925b commit a80ad39
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 5 deletions.
41 changes: 38 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const { cpus } = require('os');
const fetch = require('node-fetch');

const { app, BrowserWindow, Menu, ipcMain } = electron;
const { info } = require('electron-log');

autoUpdater.logger = log;
autoUpdater.logger.transports.file.level = 'info';
Expand All @@ -22,6 +21,20 @@ const gotTheLock = app.requestSingleInstanceLock();
const cpuCount = cpus().length;

const MenuTemplate = [
{
label: 'Updates',
submenu: [
{
label: `Version: ${app.getVersion()}`
},
{
label: 'Check for updates',
click: function(item, focusedWindow) {
autoUpdater.checkForUpdates();
}
}
]
},
{
label: 'Debugging',
submenu: [
Expand Down Expand Up @@ -83,9 +96,9 @@ if (!gotTheLock && app.isPackaged) {

if(app.isPackaged) {
log.info('starting update check');
return autoUpdater.checkForUpdates();
autoUpdater.checkForUpdates();
} else {
return currentWindow.webContents.openDevTools();
currentWindow.webContents.openDevTools();
}
});

Expand Down Expand Up @@ -133,6 +146,10 @@ if (!gotTheLock && app.isPackaged) {
if (!reload) return currentWindow.webContents.send('miner-status', { type, status: false });
}

const res = await checkPool();
console.log(res, 'res');
if(!res) return;

if (!['cpu','gpu'].includes(type)) return log.info(`No CPU or GPU as mining type! ${type}`);

const resourcesPath = join(app.getAppPath(), app.isPackaged ? '..' : '');
Expand Down Expand Up @@ -227,4 +244,22 @@ if (!gotTheLock && app.isPackaged) {
autoUpdater.quitAndInstall();
}, 3000);
});
}

const checkPool = async () => {
try {
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
const res = await fetch('https://gulf.moneroocean.stream');
process.env.NODE_TLS_REJECT_UNAUTHORIZED = undefined;
const text = await res.text();
if (text !== 'Mining Pool Online') {
currentWindow.webContents.send('pool-status', { online: false });
return false;
} else {
return true;
}
} catch (e) {
currentWindow.webContents.send('pool-status', { online: false });
return false;
}
}
6 changes: 5 additions & 1 deletion js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@ ipcRenderer.on('resetXmrigStatus', (event, { type, message }) => {
modal.hide();

return log.innerHTML += `<tr><th scope=\"row\">${type}</th><th>${message}</th></tr>`
})
});

ipcRenderer.on('pool-status', (event, { online }) => {
if (!online) return log.innerHTML += `<tr><th scope=\"row\">pool</th><th>Can't connect to the pool, please try again later</th></tr>`;
});

const getUsername = () => {
const username = userNameInput.value;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "robinsch-miner",
"version": "1.1.1",
"version": "1.1.2",
"description": "My xmrig GUI miner",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit a80ad39

Please sign in to comment.