mirror of
https://github.com/jwinterm/nodejs-pool.git
synced 2026-10-17 05:21:27 +02:00
Initial commit, moving from private repo. Welcome to the light.
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
"use strict";
|
||||
let mysql = require("promise-mysql");
|
||||
let fs = require("fs");
|
||||
let argv = require('minimist')(process.argv.slice(2));
|
||||
let config = fs.readFileSync("../config.json");
|
||||
let coinConfig = fs.readFileSync("../coinConfig.json");
|
||||
let protobuf = require('protocol-buffers');
|
||||
const request = require('request');
|
||||
|
||||
global.support = require("../lib/support.js")();
|
||||
global.config = JSON.parse(config);
|
||||
global.mysql = mysql.createPool(global.config.mysql);
|
||||
global.protos = protobuf(fs.readFileSync('../lib/data.proto'));
|
||||
let comms;
|
||||
let coinInc;
|
||||
|
||||
|
||||
// Config Table Layout
|
||||
// <module>.<item>
|
||||
|
||||
global.mysql.query("SELECT * FROM config").then(function (rows) {
|
||||
rows.forEach(function (row){
|
||||
if (!global.config.hasOwnProperty(row.module)){
|
||||
global.config[row.module] = {};
|
||||
}
|
||||
if (global.config[row.module].hasOwnProperty(row.item)){
|
||||
return;
|
||||
}
|
||||
switch(row.item_type){
|
||||
case 'int':
|
||||
global.config[row.module][row.item] = parseInt(row.item_value);
|
||||
break;
|
||||
case 'bool':
|
||||
global.config[row.module][row.item] = (row.item_value === "true");
|
||||
break;
|
||||
case 'string':
|
||||
global.config[row.module][row.item] = row.item_value;
|
||||
break;
|
||||
case 'float':
|
||||
global.config[row.module][row.item] = parseFloat(row.item_value);
|
||||
break;
|
||||
}
|
||||
});
|
||||
}).then(function(){
|
||||
global.config['coin'] = JSON.parse(coinConfig)[global.config.coin];
|
||||
coinInc = require("." + global.config.coin.funcFile);
|
||||
global.coinFuncs = new coinInc();
|
||||
if (argv.module === 'pool'){
|
||||
comms = require('../lib/remote_comms');
|
||||
} else {
|
||||
comms = require('../lib/local_comms');
|
||||
}
|
||||
global.database = new comms();
|
||||
global.database.initEnv();
|
||||
global.coinFuncs.blockedAddresses.push(global.config.pool.address);
|
||||
global.coinFuncs.blockedAddresses.push(global.config.payout.feeAddress);
|
||||
}).then(function(){
|
||||
global.database.fixBlockShares(1241110);
|
||||
});
|
||||
Reference in New Issue
Block a user