Merge pull request #9 from Snipa22/sql_fixes

Sql fixes
This commit is contained in:
Snipa22
2017-02-11 12:02:03 -08:00
committed by GitHub
5 changed files with 563 additions and 8 deletions
+14 -6
View File
@@ -58,12 +58,12 @@ Deployment via Installer
8. Once you're happy with the settings, go ahead and start all the pool daemons, commands follow.
```bash
pm2 start init.js --name=blockManager -- --module=blockManager
pm2 start init.js --name=worker -- --module=worker
pm2 start init.js --name=payments -- --module=payments
pm2 start init.js --name=remoteShare -- --module=remoteShare
pm2 start init.js --name=longRunner -- --module=longRunner
pm2 start init.js --name=pool -- --module=pool
pm2 start init.js --name=blockManager --log-date-format="YYYY-MM-DD HH:mm Z" -- --module=blockManager
pm2 start init.js --name=worker --log-date-format="YYYY-MM-DD HH:mm Z" -- --module=worker
pm2 start init.js --name=payments --log-date-format="YYYY-MM-DD HH:mm Z" -- --module=payments
pm2 start init.js --name=remoteShare --log-date-format="YYYY-MM-DD HH:mm Z" -- --module=remoteShare
pm2 start init.js --name=longRunner --log-date-format="YYYY-MM-DD HH:mm Z" -- --module=longRunner
pm2 start init.js --name=pool --log-date-format="YYYY-MM-DD HH:mm Z" -- --module=pool
pm2 restart api
```
@@ -141,6 +141,14 @@ The email field is used as the default password field until the password is chan
You should take a look at the [wiki](https://github.com/Snipa22/nodejs-pool/wiki/Configuration-Details) for specific configuration settings in the system.
Pool Update Procedures
======================
If upgrading the pool, please do a git pull to get the latest code within the pool's directory.
Once complete, please cd into sql_sync, then run node sql_sync.js
This will update your pool with the latest config options with any defaults that the pools may set.
Pool Troubleshooting
====================
+1 -1
View File
@@ -87,5 +87,5 @@ pm2 install pm2-logrotate
mysql -u root --password=$ROOT_SQL_PASS < deployment/base.sql
mysql -u root --password=$ROOT_SQL_PASS pool -e "INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('api', 'authKey', '`cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1`', 'string', 'Auth key sent with all Websocket frames for validation.')"
mysql -u root --password=$ROOT_SQL_PASS pool -e "INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('api', 'secKey', '`cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1`', 'string', 'HMAC key for Passwords. JWT Secret Key. Changing this will invalidate all current logins.')"
pm2 start init.js --name=api -- --module=api
pm2 start init.js --name=api --log-date-format="YYYY-MM-DD HH:mm Z" -- --module=api
echo "You're setup! Please read the rest of the readme for the remainder of your setup and configuration. These steps include: Setting your Fee Address, Pool Address, Global Domain, and the Mailgun setup!"
+1 -1
View File
@@ -1,5 +1,5 @@
UPDATE pool.config SET item_value = '' WHERE module = 'pool' and item = 'address';
UPDATE pool.config SET item_value = '' WHERE module = 'pool' and item = 'feeAddress';
UPDATE pool.config SET item_value = '' WHERE module = 'payout' and item = 'feeAddress';
UPDATE pool.config SET item_value = '' WHERE module = 'general' and item = 'mailgunKey';
UPDATE pool.config SET item_value = '' WHERE module = 'general' and item = 'mailgunURL';
UPDATE pool.config SET item_value = '' WHERE module = 'general' and item = 'emailFrom';
+514
View File
@@ -0,0 +1,514 @@
[
{
"id": 1,
"module": "pool",
"item": "address",
"item_value": "",
"item_type": "string",
"Item_desc": "Address to mine to, this should be the wallet-rpc address."
},
{
"id": 2,
"module": "pool",
"item": "minerTimeout",
"item_value": "900",
"item_type": "int",
"Item_desc": "Length of time before a miner is flagged inactive."
},
{
"id": 3,
"module": "pool",
"item": "banEnabled",
"item_value": "true",
"item_type": "bool",
"Item_desc": "Enables/disabled banning of \"bad\" miners."
},
{
"id": 4,
"module": "pool",
"item": "banLength",
"item_value": "-15m",
"item_type": "string",
"Item_desc": "Ban duration except perma-bans"
},
{
"id": 5,
"module": "pool",
"item": "targetTime",
"item_value": "30",
"item_type": "int",
"Item_desc": "Time in seconds between share finds"
},
{
"id": 6,
"module": "pool",
"item": "trustThreshold",
"item_value": "30",
"item_type": "int",
"Item_desc": "Number of shares before miner trust can kick in."
},
{
"id": 8,
"module": "pool",
"item": "banPercent",
"item_value": "25",
"item_type": "int",
"Item_desc": "Percentage of shares that need to be invalid to be banned."
},
{
"id": 9,
"module": "pool",
"item": "banThreshold",
"item_value": "30",
"item_type": "int",
"Item_desc": "Number of shares before bans can begin"
},
{
"id": 10,
"module": "pool",
"item": "trustedMiners",
"item_value": "true",
"item_type": "bool",
"Item_desc": "Enable the miner trust system"
},
{
"id": 11,
"module": "pool",
"item": "trustChange",
"item_value": "1",
"item_type": "int",
"Item_desc": "Change in the miner trust in percent"
},
{
"id": 12,
"module": "pool",
"item": "trustMin",
"item_value": "20",
"item_type": "int",
"Item_desc": "Minimum level of miner trust"
},
{
"id": 13,
"module": "pool",
"item": "trustPenalty",
"item_value": "30",
"item_type": "int",
"Item_desc": "Number of shares that must be successful to be trusted, reset to this value if trust share is broken"
},
{
"id": 14,
"module": "pool",
"item": "retargetTime",
"item_value": "60",
"item_type": "int",
"Item_desc": "Time between difficulty retargets"
},
{
"id": 15,
"module": "daemon",
"item": "address",
"item_value": "127.0.0.1",
"item_type": "string",
"Item_desc": "Monero Daemon RPC IP"
},
{
"id": 16,
"module": "daemon",
"item": "port",
"item_value": "18081",
"item_type": "int",
"Item_desc": "Monero Daemon RPC Port"
},
{
"id": 17,
"module": "wallet",
"item": "address",
"item_value": "127.0.0.1",
"item_type": "string",
"Item_desc": "Monero Daemon RPC Wallet IP"
},
{
"id": 18,
"module": "wallet",
"item": "port",
"item_value": "37458",
"item_type": "int",
"Item_desc": "Monero Daemon RPC Wallet Port"
},
{
"id": 21,
"module": "rpc",
"item": "https",
"item_value": "false",
"item_type": "bool",
"Item_desc": "Enable RPC over SSL"
},
{
"id": 22,
"module": "pool",
"item": "maxDifficulty",
"item_value": "500000",
"item_type": "int",
"Item_desc": "Maximum difficulty for VarDiff"
},
{
"id": 23,
"module": "pool",
"item": "minDifficulty",
"item_value": "100",
"item_type": "int",
"Item_desc": "Minimum difficulty for VarDiff"
},
{
"id": 24,
"module": "pool",
"item": "varDiffVariance",
"item_value": "20",
"item_type": "int",
"Item_desc": "Percentage out of the target time that difficulty changes"
},
{
"id": 25,
"module": "pool",
"item": "varDiffMaxChange",
"item_value": "30",
"item_type": "int",
"Item_desc": "Percentage amount that the difficulty may change"
},
{
"id": 27,
"module": "payout",
"item": "btcFee",
"item_value": "1.5",
"item_type": "float",
"Item_desc": "Fee charged for auto withdrawl via BTC"
},
{
"id": 28,
"module": "payout",
"item": "ppsFee",
"item_value": "6.5",
"item_type": "float",
"Item_desc": "Fee charged for usage of the PPS pool"
},
{
"id": 29,
"module": "payout",
"item": "pplnsFee",
"item_value": ".6",
"item_type": "float",
"Item_desc": "Fee charged for the usage of the PPLNS pool"
},
{
"id": 30,
"module": "payout",
"item": "propFee",
"item_value": ".7",
"item_type": "float",
"Item_desc": "Fee charged for the usage of the proportial pool"
},
{
"id": 31,
"module": "payout",
"item": "soloFee",
"item_value": ".4",
"item_type": "float",
"Item_desc": "Fee charged for usage of the solo mining pool"
},
{
"id": 32,
"module": "payout",
"item": "exchangeMin",
"item_value": "5",
"item_type": "float",
"Item_desc": "Minimum XMR balance for payout to exchange/payment ID"
},
{
"id": 33,
"module": "payout",
"item": "walletMin",
"item_value": ".3",
"item_type": "float",
"Item_desc": "Minimum XMR balance for payout to personal wallet"
},
{
"id": 34,
"module": "payout",
"item": "devDonation",
"item_value": "5",
"item_type": "float",
"Item_desc": "Donation to XMR core development"
},
{
"id": 35,
"module": "payout",
"item": "poolDevDonation",
"item_value": "0",
"item_type": "float",
"Item_desc": "Donation to pool developer"
},
{
"id": 36,
"module": "payout",
"item": "denom",
"item_value": ".000001",
"item_type": "float",
"Item_desc": "Minimum balance that will be paid out to."
},
{
"id": 37,
"module": "payout",
"item": "blocksRequired",
"item_value": "60",
"item_type": "int",
"Item_desc": "Blocks required to validate a payout before it's performed."
},
{
"id": 38,
"module": "general",
"item": "sigDivisor",
"item_value": "1000000000000",
"item_type": "int",
"Item_desc": "Divisor for turning coin into human readable amounts "
},
{
"id": 39,
"module": "payout",
"item": "feeAddress",
"item_value": "",
"item_type": "string",
"Item_desc": "Address that pool fees are sent to."
},
{
"id": 40,
"module": "payout",
"item": "feesForTXN",
"item_value": "10",
"item_type": "int",
"Item_desc": "Amount of XMR that is left from the fees to pay miner fees."
},
{
"id": 41,
"module": "payout",
"item": "maxTxnValue",
"item_value": "250",
"item_type": "int",
"Item_desc": "Maximum amount of XMR to send in a single transaction"
},
{
"id": 42,
"module": "payout",
"item": "shapeshiftPair",
"item_value": "xmr_btc",
"item_type": "string",
"Item_desc": "Pair to use in all shapeshift lookups for auto BTC payout"
},
{
"id": 43,
"module": "general",
"item": "coinCode",
"item_value": "XMR",
"item_type": "string",
"Item_desc": "Coincode to be loaded up w/ the shapeshift getcoins argument."
},
{
"id": 44,
"module": "general",
"item": "allowBitcoin",
"item_value": "true",
"item_type": "bool",
"Item_desc": "Allow the pool to auto-payout to BTC via ShapeShift"
},
{
"id": 45,
"module": "payout",
"item": "exchangeRate",
"item_value": "1217200",
"item_type": "float",
"Item_desc": "Current exchange rate"
},
{
"id": 46,
"module": "payout",
"item": "bestExchange",
"item_value": "xmrto",
"item_type": "string",
"Item_desc": "Current best exchange"
},
{
"id": 47,
"module": "payout",
"item": "mixIn",
"item_value": "4",
"item_type": "int",
"Item_desc": "Mixin count for coins that support such things."
},
{
"id": 48,
"module": "pool",
"item": "geoDNS",
"item_value": "",
"item_type": "string",
"Item_desc": "geoDNS enabled address for the pool."
},
{
"id": 49,
"module": "general",
"item": "statsBufferLength",
"item_value": "120",
"item_type": "int",
"Item_desc": "Number of items to be cached in the stats buffers."
},
{
"id": 50,
"module": "api",
"item": "authKey",
"item_value": "",
"item_type": "string",
"Item_desc": "Auth key sent with all Websocket frames for validation"
},
{
"id": 51,
"module": "general",
"item": "mailgunKey",
"item_value": "",
"item_type": "string",
"Item_desc": "MailGun API Key for notification"
},
{
"id": 52,
"module": "general",
"item": "mailgunURL",
"item_value": "",
"item_type": "string",
"Item_desc": "MailGun URL for notifications"
},
{
"id": 53,
"module": "general",
"item": "emailFrom",
"item_value": "",
"item_type": "string",
"Item_desc": "From address for the notification emails"
},
{
"id": 54,
"module": "pps",
"item": "enable",
"item_value": "false",
"item_type": "bool",
"Item_desc": "Enable PPS or not"
},
{
"id": 55,
"module": "pplns",
"item": "shareMulti",
"item_value": "2",
"item_type": "int",
"Item_desc": "Multiply this times difficulty to set the N in PPLNS"
},
{
"id": 56,
"module": "pplns",
"item": "shareMultiLog",
"item_value": "3",
"item_type": "int",
"Item_desc": "How many times the difficulty of the current block do we keep in shares before clearing them out"
},
{
"id": 57,
"module": "general",
"item": "blockCleaner",
"item_value": "true",
"item_type": "bool",
"Item_desc": "Enable the deletion of blocks or not."
},
{
"id": 58,
"module": "api",
"item": "secKey",
"item_value": "",
"item_type": "string",
"Item_desc": "HMAC key for Passwords. JWT Secret Key"
},
{
"id": 59,
"module": "payout",
"item": "feeSlewAmount",
"item_value": ".011",
"item_type": "float",
"Item_desc": "Amount to charge for the txn fee"
},
{
"id": 60,
"module": "payout",
"item": "feeSlewEnd",
"item_value": "4",
"item_type": "float",
"Item_desc": "Value at which txn fee amount drops to 0"
},
{
"id": 61,
"module": "general",
"item": "testnet",
"item_value": "false",
"item_type": "bool",
"Item_desc": "Does this pool use testnet?"
},
{
"id": 62,
"module": "pplns",
"item": "enable",
"item_value": "true",
"item_type": "bool",
"Item_desc": "Enable PPLNS on the pool."
},
{
"id": 63,
"module": "solo",
"item": "enable",
"item_value": "true",
"item_type": "bool",
"Item_desc": "Enable SOLO mining on the pool"
},
{
"id": 64,
"module": "general",
"item": "adminEmail",
"item_value": "",
"item_type": "string",
"Item_desc": "Admin e-mail to send e-mails to when something isn't working right."
},
{
"id": 65,
"module": "payout",
"item": "rpcPasswordEnabled",
"item_value": "false",
"item_type": "bool",
"Item_desc": "Does the wallet use a RPC password?"
},
{
"id": 66,
"module": "payout",
"item": "rpcPasswordPath",
"item_value": "",
"item_type": "string",
"Item_desc": "Path and file for the RPC password file location"
},
{
"id": 67,
"module": "payout",
"item": "maxPaymentTxns",
"item_value": "5",
"item_type": "int",
"Item_desc": "Maximum number of transactions in a single payment"
},
{
"id": 68,
"module": "general",
"item": "shareHost",
"item_value": "",
"item_type": "string",
"Item_desc": "Host that receives share information"
}
]
+33
View File
@@ -0,0 +1,33 @@
"use strict";
let mysql = require("promise-mysql");
let fs = require("fs");
let config = fs.readFileSync("../config.json");
let sql_schema = fs.readFileSync("config_entries.json");
global.config = JSON.parse(config);
global.mysql = mysql.createPool(global.config.mysql);
global.schema = JSON.parse(sql_schema);
// Config Table Layout
// <module>.<item>
let loopCount = 0;
let updatedCount = 0;
global.schema.forEach(function(entry){
global.mysql.query("SELECT * FROM config WHERE module = ? AND item = ?", [entry.module, entry.item]).then(function(rows){
loopCount += 1;
if (rows.length > 0){
if(loopCount === global.schema.length){
console.log("Updated SQL schema with "+updatedCount+" new rows! Exiting!");
process.exit();
}
return;
}
updatedCount += 1;
global.mysql.query("INSERT INTO config (module, item, item_value, item_type, Item_desc) VALUES (?, ?, ?, ?, ?)", [entry.module, entry.item, entry.item_value, entry.item_type, entry.Item_desc]);
if(loopCount === global.schema.length){
console.log("Updated SQL schema with "+updatedCount+" new rows! Exiting!");
process.exit();
}
});
});