Changes to setting vardiff (for coin-switching). Added pubkey to address function
This commit is contained in:
parent
89e9f47e47
commit
fe64fb8855
@ -221,7 +221,7 @@ var pool = module.exports = function pool(options, authorizeFn){
|
||||
_this.varDiff = {};
|
||||
Object.keys(options.ports).forEach(function(port) {
|
||||
if (options.ports[port].varDiff)
|
||||
_this.setVarDiff(port, new varDiff(port, options.ports[port].varDiff));
|
||||
_this.setVarDiff(port, options.ports[port].varDiff);
|
||||
});
|
||||
}
|
||||
|
||||
@ -641,10 +641,11 @@ var pool = module.exports = function pool(options, authorizeFn){
|
||||
};
|
||||
|
||||
|
||||
this.setVarDiff = function(port, varDiffInstance) {
|
||||
this.setVarDiff = function(port, varDiffConfig) {
|
||||
if (typeof(_this.varDiff[port]) != 'undefined' ) {
|
||||
_this.varDiff[port].removeAllListeners();
|
||||
}
|
||||
var varDiffInstance = new varDiff(port, varDiffConfig);
|
||||
_this.varDiff[port] = varDiffInstance;
|
||||
_this.varDiff[port].on('newDifficulty', function(client, newDiff) {
|
||||
|
||||
|
||||
@ -119,7 +119,7 @@ var StratumClient = function(options){
|
||||
function handleAuthorize(message, replyToSocket){
|
||||
_this.workerName = message.params[0];
|
||||
_this.workerPass = message.params[1];
|
||||
options.authorizeFn(_this.remoteAddress, _this.workerName, _this.workerPass, function(result) {
|
||||
options.authorizeFn(_this.remoteAddress, options.socket.localPort, _this.workerName, _this.workerPass, function(result) {
|
||||
_this.authorized = (!result.error && result.authorized);
|
||||
|
||||
if (replyToSocket) {
|
||||
|
||||
13
lib/util.js
13
lib/util.js
@ -4,6 +4,19 @@ var base58 = require('base58-native');
|
||||
var bignum = require('bignum');
|
||||
|
||||
|
||||
exports.addressFromEx = function(exAddress, ripdm160Key){
|
||||
try {
|
||||
var versionByte = base58.decode(exAddress).slice(0, 1);
|
||||
var addrBase = Buffer.concat([versionByte, new Buffer(ripdm160Key, 'hex')]);
|
||||
var checksum = exports.sha256d(addrBase).slice(0, 4);
|
||||
var address = Buffer.concat([addrBase, checksum]);
|
||||
return base58.encode(address);
|
||||
}
|
||||
catch(e){
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
exports.sha256 = function(buffer){
|
||||
var hash1 = crypto.createHash('sha256');
|
||||
|
||||
Loading…
Reference in New Issue
Block a user