-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewrite of core logic, nodeminer will now poll each configured miner …
…on the server side and only emit updates to the client on socket connect (this applies to pool & coin configuration as well)
- Loading branch information
1 parent
41c7543
commit 11c64e1
Showing
8 changed files
with
596 additions
and
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,23 @@ | ||
var minerApi = require('../modules/bfgminer'); | ||
|
||
'use strict'; | ||
|
||
/** | ||
* Get awesome things | ||
*/ | ||
exports.pingMiner = function (req, res) { | ||
var MinerService = new (require('../services/MinersService.js'))(); | ||
|
||
exports.ping = function (req, res) { | ||
var hostName = req.params.hostname; | ||
var port = req.params.port; | ||
|
||
minerApi.ping({ host: hostName, port: port }, function (err, data) { | ||
if (err) { | ||
res.json({ | ||
host: hostName, | ||
port: port, | ||
online: false | ||
}); | ||
} else { | ||
res.json({ | ||
host: hostName, | ||
port: port, | ||
online: true, | ||
status: data | ||
}); | ||
} | ||
MinerService.ping({ host: hostName, port: port}).then(function (data) { | ||
res.json({ | ||
host: hostName, | ||
port: port, | ||
online: true, | ||
status: data | ||
}); | ||
}, function (err) { | ||
res.json({ | ||
host: hostName, | ||
port: port, | ||
online: false | ||
}); | ||
}); | ||
}; |
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
var _ = require('lodash'); | ||
|
||
exports.parseDevDetails = function (miner, response) { | ||
var data; | ||
|
||
|
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,61 @@ | ||
/** | ||
* Dependencies | ||
*/ | ||
|
||
var EventEmitter = require('events').EventEmitter, | ||
util = require('util'), | ||
fs = require('fs'), | ||
path = require('path'), | ||
_ = require('lodash'), | ||
helpers = require('../helpers'); | ||
|
||
function CoinsService() { | ||
EventEmitter.call(this); | ||
var self = this; | ||
|
||
if (!self.coins || self.coins.length == 0) { | ||
self.load(); | ||
} | ||
}; | ||
|
||
util.inherits(CoinsService, EventEmitter); | ||
|
||
CoinsService.prototype.load = function () { | ||
var self = this; | ||
|
||
var file = path.normalize(__dirname + "/../config/coins.json"); | ||
|
||
try { | ||
var data = fs.readFileSync(file, 'utf8'); | ||
|
||
this.coins = JSON.parse(data); | ||
|
||
} catch (err) { | ||
setTimeout(function() { | ||
self.emit('fileError', { msg: 'Error reading coin configuration', data: err }); | ||
}, 0); | ||
} | ||
}; | ||
|
||
CoinsService.prototype.save = function (coins) { | ||
var self = this; | ||
|
||
var file = path.normalize(__dirname + "/../config/coins.json"); | ||
|
||
fs.writeFile(file, JSON.stringify(coins, null, 4), function (err) { | ||
if (err) { | ||
setTimeout(function() { | ||
self.emit('fileError', { msg: 'Error saving coin configuration', data: err }); | ||
}, 0); | ||
return; | ||
} | ||
|
||
setTimeout(function() { | ||
self.emit('saved', coins); | ||
self.coins = coins; | ||
}, 0); | ||
}); | ||
}; | ||
|
||
module.exports = CoinsService; | ||
|
Oops, something went wrong.