Made ban purge interval a config

This commit is contained in:
Matt 2014-03-06 14:27:23 -07:00
parent 11cb76ee1f
commit bd2de18dab
2 changed files with 42 additions and 37 deletions

View File

@ -86,11 +86,13 @@ var pool = Stratum.createPool({
txMessages: false //or true txMessages: false //or true
}, },
"address": "mi4iBXbBsydtcc5yFmsff2zCFVX4XG7qJc", //Address to where block rewards are given
"blockRefreshInterval": 1000 //How often to poll RPC daemons for new blocks, in milliseconds
//instanceId: 37, //Recommend not using this because a crypto-random one will be generated //instanceId: 37, //Recommend not using this because a crypto-random one will be generated
/* Some attackers will create thousands of workers that use up all available socket connections, /* Some attackers will create thousands of workers that use up all available socket connections,
usually the workers are zombies and don't submit shares after connecting. This features usually the workers are zombies and don't submit shares after connecting. This features
detects those and disconnects them */ detects those and disconnects them. */
"connectionTimeout": 120, //Remove workers that haven't been in contact for this many seconds "connectionTimeout": 120, //Remove workers that haven't been in contact for this many seconds
/* If a worker is submitting a good deal of invalid shares we can temporarily ban them to /* If a worker is submitting a good deal of invalid shares we can temporarily ban them to
@ -99,66 +101,69 @@ var pool = Stratum.createPool({
"enabled": true, "enabled": true,
"time": 600, //How many seconds to ban worker for "time": 600, //How many seconds to ban worker for
"invalidPercent": 50, //What percent of invalid shares triggers ban "invalidPercent": 50, //What percent of invalid shares triggers ban
"checkThreshold": 500 //Check invalid percent when this many shares have been submitted "checkThreshold": 500, //Check invalid percent when this many shares have been submitted
"purgeInterval": 300 //Every this many seconds clear out the list of old bans
}, },
/* Each pool can have as many ports for your miners to connect to as you wish. Each port can /* Each pool can have as many ports for your miners to connect to as you wish. Each port can
be configured to use its own pool difficulty and variable difficulty settings. varDiff is be configured to use its own pool difficulty and variable difficulty settings. varDiff is
optional and will only be used for the ports you configure it for. */ optional and will only be used for the ports you configure it for. */
"ports": { "ports": {
"3032": { //a port for your miners to connect to "3032": { //A port for your miners to connect to
"diff": 32, //the pool difficulty for this port "diff": 32, //the pool difficulty for this port
/* Variable difficulty is a feature that will automatically adjust difficulty for /* Variable difficulty is a feature that will automatically adjust difficulty for
individual miners based on their hashrate in order to lower networking overhead */ individual miners based on their hashrate in order to lower networking overhead */
"varDiff": { "varDiff": {
"minDiff": 8, //minimum difficulty "minDiff": 8, //Minimum difficulty
"maxDiff": 512, //network difficulty will be used if it is lower than this "maxDiff": 512, //Network difficulty will be used if it is lower than this
"targetTime": 15, //try to get 1 share per this many seconds "targetTime": 15, //Try to get 1 share per this many seconds
"retargetTime": 90, //check to see if we should retarget every this many seconds "retargetTime": 90, //Check to see if we should retarget every this many seconds
"variancePercent": 30 //allow time to very this % from target without retargeting "variancePercent": 30 //Allow time to very this % from target without retargeting
} }
}, },
"3256": { //another port for your miners to connect to, this port does not use varDiff "3256": { //Another port for your miners to connect to, this port does not use varDiff
"diff": 256 //the pool difficulty "diff": 256 //The pool difficulty
} }
}, },
/* Recommended to have at least two daemon instances running in case one drops out-of-sync /* Recommended to have at least two daemon instances running in case one drops out-of-sync
or offline. For redundancy, all instances will be polled for block/transaction updates or offline. For redundancy, all instances will be polled for block/transaction updates
and be used for submitting blocks */ and be used for submitting blocks. */
daemons: [ "daemons": [
{ //main daemon instance { //Main daemon instance
host: "localhost", "host": "localhost",
port: 19334, "port": 19332,
user: "testnet", "user": "litecoinrpc",
password: "testnet" "password": "testnet"
}, },
{ //backup daemon instance { //Backup daemon instance
host: "localhost", "host": "localhost",
port: 19335, "port": 19344,
user: "testnet", "user": "litecoinrpc",
password: "testnet" "password": "testnet"
} }
], ],
p2p: {
enabled: false, /* This allows the pool to connect to the daemon as a node peer to recieve block updates.
host: "localhost", It may be the most efficient way to get block updates (faster than polling, less
port: 19333, intensive than blocknotify script). However its still under development (not yet working). */
"p2p": {
"enabled": false,
"host": "localhost",
"port": 19333,
/* Magic value is different for main/testnet and for each coin. It is found in the daemon /* 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: source code as the pchMessageStart variable.
http://github.com/litecoin-project/litecoin/blob/85f303d883ffff35238eaea5174b780c950c0ae4/src/main.cpp#L3059 For example, litecoin mainnet magic: http://git.io/Bi8YFw
And for litecoin testnet: And for litecoin testnet magic: http://git.io/NXBYJA
http://github.com/litecoin-project/litecoin/blob/85f303d883ffff35238eaea5174b780c950c0ae4/src/main.cpp#L2722-L2725
*/ */
magic: "fcc1b7dc", "magic": "fcc1b7dc",
/* Found in src as the PROTOCOL_VERSION variable, for example: //Found in src as the PROTOCOL_VERSION variable, for example: http://git.io/KjuCrw
https://github.com/litecoin-project/litecoin/blob/85f303d883ffff35238eaea5174b780c950c0ae4/src/version.h#L28 "protocolVersion": 70002,
*/
protocolVersion: 70002
} }
}, function(ip, workerName, password, callback){ //stratum authorization function }, function(ip, workerName, password, callback){ //stratum authorization function

View File

@ -298,14 +298,14 @@ var StratumServer = exports.Server = function StratumServer(ports, connectionTim
var bannedIPs = {}; var bannedIPs = {};
//Every 5 minutes look through bannedIPs for old bans and remove them in order to prevent a memory leak //Interval to look through bannedIPs for old bans and remove them in order to prevent a memory leak
var purgeOldBans = !banning.enabled ? null : setInterval(function(){ var purgeOldBans = !banning.enabled ? null : setInterval(function(){
for (ip in bannedIPs){ for (ip in bannedIPs){
var banTime = bannedIPs[ip]; var banTime = bannedIPs[ip];
if (Date.now() - banTime > banning.time) if (Date.now() - banTime > banning.time)
delete bannedIPs[ip]; delete bannedIPs[ip];
} }
}, 1000 * 60 * 5); //5 minutes }, 1000 * banning.purgeInterval);
var handleNewClient = function (socket) { var handleNewClient = function (socket) {
socket.setKeepAlive(true); socket.setKeepAlive(true);