Skip to content

Commit

Permalink
Added rewardRecipients configuration, refactored payment processing, …
Browse files Browse the repository at this point in the history
…moved p2p magic to coin config
  • Loading branch information
zone117x committed May 2, 2014
1 parent 80be932 commit 7366870
Show file tree
Hide file tree
Showing 11 changed files with 427 additions and 652 deletions.
166 changes: 76 additions & 90 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -284,13 +284,22 @@ Here is an example of the required fields:
{
"name": "Litecoin",
"symbol": "ltc",
"algorithm": "scrypt", //or "sha256", "scrypt-jane", "scrypt-n", "quark", "x11"
"txMessages": false, //or true (not required, defaults to false)
"mposDiffMultiplier": 256, //only for x11 coins in mpos mode, set to 256 (optional)
"algorithm": "scrypt",

/* Magic value only required for setting up p2p block notifications. It is found in the daemon
source code as the pchMessageStart variable.
For example, litecoin mainnet magic: http://git.io/Bi8YFw
And for litecoin testnet magic: http://git.io/NXBYJA */
"peerMagic": "fbc0b6db" //optional
"peerMagicTestnet": "fcc1b7dc" //optional

//"txMessages": false, //options - defaults to false

//"mposDiffMultiplier": 256, //options - only for x11 coins in mpos mode
}
````

For additional documentation how to configure coins *(especially important for scrypt-n and scrypt-jane coins)*
For additional documentation how to configure coins and their different algorithms
see [these instructions](//github.com/zone117x/node-stratum-pool#module-usage).


Expand All @@ -307,6 +316,17 @@ Description of options:

"address": "mi4iBXbBsydtcc5yFmsff2zCFVX4XG7qJc", //Address to where block rewards are given

/* Block rewards go to the configured pool wallet address to later be paid out to miners,
except for a percentages that can go to pool operator(s) as pool fees or donations.
Addresses or hashed public keys can be used. */
"rewardRecipients": {
"n37vuNFkXfk15uFnGoVyHZ6PYQxppD3QqK": 1.5, //1.5% goes to pool op
"mirj3LtZxbSTharhtXvotqtJXUY7ki5qfx": 0.5, //0.5% goes to a pool co-owner

//0.1% donation to NOMP to help support development
"22851477d63a085dbc2398c8430af1c09e7343f6": 0.1
},

"blockRefreshInterval": 1000, //How often to poll RPC daemons for new blocks, in milliseconds

/* How many milliseconds should have passed before new block transactions will trigger a new
Expand All @@ -332,96 +352,68 @@ Description of options:
miners/pools that deal with scrypt use a guesstimated one that is about 5.86% off from the
actual one. So here we can set a tolerable threshold for if a share is slightly too low
due to mining apps using incorrect max diffs and this pool using correct max diffs. */
"shareVariancePercent": 10,
"shareVariancePercent": 2,

/* Enable for client IP addresses to be detected when using a load balancer with TCP proxy
protocol enabled, such as HAProxy with 'send-proxy' param:
http://haproxy.1wt.eu/download/1.5/doc/configuration.txt */
"tcpProxyProtocol": false,

/* To receive payments, miners must connect with their address or mining key as their username.
This option will only authenticate miners using an address or mining key. */
"validateWorkerAddress": true,

/* This determines what to do with submitted shares (and stratum worker authentication).
You have two options:
1) Enable internal and disable mpos = this portal to handle all share payments.
2) Enable mpos and disable internal = shares will be inserted into MySQL database
for MPOS to process. */
"shareProcessing": {
"paymentProcessing": {
"enabled": true,

"internal": {
"enabled": true,
/* Every this many seconds get submitted blocks from redis, use daemon RPC to check
their confirmation status, if confirmed then get shares from redis that contributed
to block and send out payments. */
"paymentInterval": 30,

/* When workers connect, to receive payments, their address must be used as the worker
name. If this option is true, on worker authentication, their address will be
verified via a validateaddress API call to the daemon. Miners with invalid addresses
will be rejected. */
"validateWorkerAddress": true,

/* Every this many seconds get submitted blocks from redis, use daemon RPC to check
their confirmation status, if confirmed then get shares from redis that contributed
to block and send out payments. */
"paymentInterval": 30,

/* Minimum number of coins that a miner must earn before sending payment. Typically,
a higher minimum means less transactions fees (you profit more) but miners see
payments less frequently (they dislike). Opposite for a lower minimum payment. */
"minimumPayment": 0.001,

/* Minimum number of coins to keep in pool wallet. It is recommended to deposit at
at least this many coins into the pool wallet when first starting the pool. */
"minimumReserve": 10,

/* (2% default) What percent fee your pool takes from the block reward. */
"feePercent": 0.02,

/* Name of the daemon account to use when moving coin profit within daemon wallet. */
"feeCollectAccount": "feesCollected",

/* Your address that receives pool revenue from fees. */
"feeReceiveAddress": "LZz44iyF4zLCXJTU8RxztyyJZBntdS6fvv",

/* How many coins from fee revenue must accumulate on top of the
minimum reserve amount in order to trigger withdrawal to fee address. The higher
this threshold, the less of your profit goes to transactions fees. */
"feeWithdrawalThreshold": 5,

/* This daemon is used to send out payments. It MUST be for the daemon that owns the
configured 'address' that receives the block rewards, otherwise the daemon will not
be able to confirm blocks or send out payments. */
"daemon": {
"host": "127.0.0.1",
"port": 19332,
"user": "litecoinrpc",
"password": "testnet"
},

/* Redis database used for storing share and block submission data. */
"redis": {
"host": "127.0.0.1",
"port": 6379
}
},
/* Minimum number of coins that a miner must earn before sending payment. Typically,
a higher minimum means less transactions fees (you profit more) but miners see
payments less frequently (they dislike). Opposite for a lower minimum payment. */
"minimumPayment": 0.01,

/* Enabled mpos and shares will be inserted into share table in a MySQL database. You may
also want to use the "emitInvalidBlockHashes" option below if you require it. */
"mpos": {
"enabled": false,
"host": "127.0.0.1", //MySQL db host
"port": 3306, //MySQL db port
"user": "me", //MySQL db user
"password": "mypass", //MySQL db password
"database": "ltc", //MySQL db database name

/* Unregistered workers can automatically be registered (added to database) on stratum
worker authentication if this is true. */
"autoCreateWorker": false,

/* For when miner's authenticate: set to "password" for both worker name and password to
be checked for in the database, set to "worker" for only work name to be checked, or
don't use this option (set to "none") for no auth checks */
"stratumAuth": "password"
/* This daemon is used to send out payments. It MUST be for the daemon that owns the
configured 'address' that receives the block rewards, otherwise the daemon will not
be able to confirm blocks or send out payments. */
"daemon": {
"host": "127.0.0.1",
"port": 19332,
"user": "litecoinrpc",
"password": "testnet"
}
},

/* Redis database used for storing share and block submission data and payment processing. */
"redis": {
"host": "127.0.0.1",
"port": 6379
}

/* Enabled this mode and shares will be inserted into in a MySQL database. You may also want
to use the "emitInvalidBlockHashes" option below if you require it. The config options
"redis" and "paymentProcessing" will be ignored/unused if this is enabled. */
"mposMode": {
"enabled": false,
"host": "127.0.0.1", //MySQL db host
"port": 3306, //MySQL db port
"user": "me", //MySQL db user
"password": "mypass", //MySQL db password
"database": "ltc", //MySQL db database name

/* Checks for valid password in database when miners connect. */
"checkPassword": true,

/* Unregistered workers can automatically be registered (added to database) on stratum
worker authentication if this is true. */
"autoCreateWorker": false


},

/* If a worker is submitting a high threshold of invalid shares we can temporarily ban their IP
to reduce system/network load. Also useful to fight against flooding attacks. If running
behind something like HAProxy be sure to enable 'tcpProxyProtocol', otherwise you'll end up
Expand Down Expand Up @@ -476,8 +468,8 @@ Description of options:

/* This allows the pool to connect to the daemon as a node peer to receive block updates.
It may be the most efficient way to get block updates (faster than polling, less
intensive than blocknotify script). It requires additional setup: the 'magic' field must
be exact (extracted from the coin source code). */
intensive than blocknotify script). It requires the additional field "peerMagic" in
the coin config. */
"p2p": {
"enabled": false,

Expand All @@ -490,13 +482,7 @@ Description of options:
/* If your coin daemon is new enough (i.e. not a shitcoin) then it will support a p2p
feature that prevents the daemon from spamming our peer node with unnecessary
transaction data. Assume its supported but if you have problems try disabling it. */
"disableTransactions": true,

/* Magic value is different for main/testnet and for each coin. It is found in the daemon
source code as the pchMessageStart variable.
For example, litecoin mainnet magic: http://git.io/Bi8YFw
And for litecoin testnet magic: http://git.io/NXBYJA */
"magic": "fcc1b7dc"
"disableTransactions": true
}
}

Expand Down
4 changes: 3 additions & 1 deletion coins/litecoin.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"name": "Litecoin",
"symbol": "LTC",
"algorithm": "scrypt"
"algorithm": "scrypt",
"peerMagic": "fbc0b6db",
"peerMagicTestnet": "fcc1b7dc"
}
9 changes: 1 addition & 8 deletions init.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,6 @@ var spawnPoolWorkers = function(){

Object.keys(poolConfigs).forEach(function(coin){
var p = poolConfigs[coin];
var internalEnabled = p.shareProcessing && p.shareProcessing.internal && p.shareProcessing.internal.enabled;
var mposEnabled = p.shareProcessing && p.shareProcessing.mpos && p.shareProcessing.mpos.enabled;

if (!internalEnabled && !mposEnabled){
logger.error('Master', coin, 'Share processing is not configured so a pool cannot be started for this coin.');
delete poolConfigs[coin];
}

if (!Array.isArray(p.daemons) || p.daemons.length < 1){
logger.error('Master', coin, 'No daemons configured so a pool cannot be started for this coin.');
Expand Down Expand Up @@ -364,7 +357,7 @@ var startPaymentProcessor = function(){
var enabledForAny = false;
for (var pool in poolConfigs){
var p = poolConfigs[pool];
var enabled = p.enabled && p.shareProcessing && p.shareProcessing.internal && p.shareProcessing.internal.enabled;
var enabled = p.enabled && p.paymentProcessing && p.paymentProcessing.enabled;
if (enabled){
enabledForAny = true;
break;
Expand Down
38 changes: 18 additions & 20 deletions libs/mposCompatibility.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,30 @@ var mysql = require('mysql');
var cluster = require('cluster');
module.exports = function(logger, poolConfig){

var mposConfig = poolConfig.shareProcessing.mpos;
var mposConfig = poolConfig.mposMode;
var coin = poolConfig.coin.name;

var connection;
var connection = mysql.createPool({
host: mposConfig.host,
port: mposConfig.port,
user: mposConfig.user,
password: mposConfig.password,
database: mposConfig.database
});


var logIdentify = 'MySQL';
var logComponent = coin;

function connect(){

connection = mysql.createPool({
host: mposConfig.host,
port: mposConfig.port,
user: mposConfig.user,
password: mposConfig.password,
database: mposConfig.database
});

this.handleAuth = function(workerName, password, authCallback){

}
connect();
if (poolConfig.validateWorkerUsername !== true && mposConfig.autoCreateWorker !== true){
authCallback(true);
return;
}

this.handleAuth = function(workerName, password, authCallback){

connection.query(
'SELECT password FROM pool_worker WHERE username = LOWER(?)',
[workerName.toLowerCase()],
Expand Down Expand Up @@ -65,16 +64,15 @@ module.exports = function(logger, poolConfig){
}
}
);
}else{
}
else{
authCallback(false);
}
}
else if (mposConfig.stratumAuth === 'worker')
authCallback(true);
else if (result[0].password === password)
authCallback(true)
else
else if (mposConfig.checkPassword && result[0].password !== password)
authCallback(false);
else
authCallback(true);
}
);

Expand Down
Loading

0 comments on commit 7366870

Please sign in to comment.