Lex Pool (A rewritten pool based on uray source)



  • @Lexicon 199: if(req.minerData.xMiner.toString().startsWith('Blago'))



  • @Tate-A yeah change the rest of them to suit



  • @Lexicon

    Here from my miner:

    dl '1359691053' confirmed!  [ 15737d 3h 57m 33s ]
    2017-02-12 16:34:21.686  WARN 19156 --- [  networkPool-1] b.j.c.n.task.NetworkSubmitPoolNonceTask  : Error: Failed to submit nonce to pool: java.io.EOFException: HttpConnectionOverHTTP@28674d86(l:/10.0.0.10:51644 <-> r:/10.0.0.10:8124,closed=false)[HttpChannelOverHTTP@3d9e7d37(exchange=HttpExchange@2284caa8 req=TERMINATED/null@null res=PENDING/null@null)[send=HttpSenderOverHTTP@7691b8b7(req=QUEUED,snd=COMPLETED,failure=null)[HttpGenerator@6488d09e{s=START}],recv=HttpReceiverOverHTTP@2a317efd(rsp=IDLE,failure=null)[HttpParser{s=CLOSED,0 of 0}]]]
    2017-02-12 16:34:21.689  WARN 19156 --- [  networkPool-1] b.j.c.n.task.NetworkSubmitPoolNonceTask  : Error: Failed to submit nonce to pool: java.net.ConnectException: Connection refused
    
    

    burst-pool.js

    #!/usr/bin/env node
    var fs              = require('fs');
    var url             = require('url');
    var moment          = require('moment');
    var config          = require('./burst-pool-config');
    var poolSession     = require('./burst-pool-session');
    var poolShare       = require('./burst-pool-share');
    var poolPayment     = require('./burst-pool-payment');
    var poolProtocol    = require('./burst-pool-protocol');
    var async       = require('async');
    
    function onNewBlock(miningInfo){
        poolProtocol.clientLog("new block :");
        poolProtocol.clientLogJson(miningInfo);
    
        try{
            poolSession.updateByNewBlock(miningInfo.height,miningInfo.baseTarget, function(){
                poolShare.deleteRoundShareByDistance(config.maxRoundCount);
                poolShare.deleteAccountShareBelowThresshold(1.0,config.maxRoundCount);
                poolShare.saveSession();
                poolShare.updateByNewBlock(miningInfo.height, miningInfo.baseTarget);
                poolPayment.updateByNewBlock(miningInfo.height);
                poolPayment.saveSession();
                poolSession.saveSession();
                logMiningRound();
    
                console.log('new block #'+miningInfo.height+' BT:'+miningInfo.baseTarget+' ND:'+poolSession.getNetDiff());
                poolProtocol.getWebsocket().emit('shareList',JSON.stringify(poolShare.getCumulativeShares()));
                poolProtocol.getWebsocket().emit('blockHistory',JSON.stringify(poolSession.getState().prevBlocks));
            });
        }
        catch(e){
            console.log(e);
            console.trace();
        }
    }
    function getDateTime() {
        var date = new Date();
        var hour = date.getHours();
        hour = (hour < 10 ? "0" : "") + hour;
        var min  = date.getMinutes();
        min = (min < 10 ? "0" : "") + min;
        var sec  = date.getSeconds();
        sec = (sec < 10 ? "0" : "") + sec;
        var year = date.getFullYear();
        var month = date.getMonth() + 1;
        month = (month < 10 ? "0" : "") + month;
        var day  = date.getDate();
        day = (day < 10 ? "0" : "") + day;
        return hour + ":" + min + ":" + sec;
    }
    function logMiningRound(socket){
        var blockHeight = poolSession.getCurrentBlockHeight();
        var roundStart = poolSession.getCurrentRoundStartTime();
        var currentTime = new Date().getTime();
        var elapsed = currentTime - roundStart;
        var duration = moment.duration(elapsed).humanize(true);
        var roundShare = poolShare.getCurrentRoundShares();
        var submitters = roundShare.submitters;
        var netDiff = poolSession.getNetDiff();
        var sessionState = poolSession.getState();
        var miningInfo = {
            height      : blockHeight,
            currentTime : currentTime,
            totalShare  : roundShare.totalShare,
            submitters  : roundShare.submitters,
            roundStart  : roundStart,
            netDiff     : netDiff,
            bestDeadline: sessionState.current.bestDeadline
        };
        sessionState.current.submitters = roundShare.submitters;
        sessionState.current.totalShare = roundShare.totalShare;
    
        if(typeof socket === 'undefined'){
            poolProtocol.getWebsocket().emit('miningInfo',JSON.stringify(miningInfo));
            poolProtocol.clientLog("round #" + blockHeight + " diff "+netDiff.toFixed(1)+", elapsed " + duration + ", " + submitters + " Miners, total shares " + roundShare.totalShare.toFixed(2)+', best deadline '+roundShare.bestDeadline+' from '+roundShare.bestDeadlineAccount);
        }
        else{
            socket.emit('miningInfo',JSON.stringify(miningInfo));
            poolProtocol.clientUnicastLog(socket,"round #" + blockHeight + " diff "+netDiff.toFixed(1)+", elapsed " + duration + ", " + submitters + " Miners, total shares " + roundShare.totalShare.toFixed(2)+', best deadline '+roundShare.bestDeadline+' from '+roundShare.bestDeadlineAccount);
        }
    }
    
    function onNonceSubmitReq(req){
    
        var minerReq = null;
        try {
            minerReq = url.parse(req.url ,true);
        }
        catch (e){
            minerReq = null;
        }
    
        if( minerReq != null &&
            minerReq.hasOwnProperty('query') &&
            minerReq.query.hasOwnProperty('requestType')){
            if(minerReq.query.requestType.toLowerCase() == 'submitnonce'){
                var remoteAddr = req.connection.remoteAddress+':'+req.connection.remotePort;
                var minerData = {
                    nonce : 0,
                    from : remoteAddr,
    				xMiner : ''
    
                };
                req.url = '/burst?requestType=submitNonce';
    
                if(minerReq.query.hasOwnProperty('nonce')){
                    req.url+= '&nonce='+minerReq.query.nonce;
                    minerData.nonce = parseInt(minerReq.query.nonce);
                }
    			        if(req.headers.hasOwnProperty('x-miner')){
                       minerData.xMiner = req.headers['x-miner'];
                          }
                if(minerReq.query.hasOwnProperty('accountId')){ //<------ POOL MINING
                    req.url+= '&accountId='+minerReq.query.accountId;
                    minerData.accountId = minerReq.query.accountId;
    
                    minerReq.query.secretPhrase = config.poolPvtKey;
                    req.url+= '&secretPhrase='+config.poolPvtKey;
                }
                else {
                    if(minerReq.query.hasOwnProperty('secretPhrase')){ //<----- SOLO MINING
                        var urlPhrase = minerReq.query.secretPhrase.replace(/%2B|%2b/g,'+');
                        req.url+= '&secretPhrase='+urlPhrase;
                    }
                }
    
                req.isSubmitNonce = true;
                req.headers['content-length'] = "0";
                req.minerData = minerData;
            }
            else if(minerReq.query.requestType.toLowerCase() == 'getmininginfo'){
                req.isMiningInfo = true;
            }
        }
    
    }
    
    function onNonceSubmitedRes(req,res){
        if(req.hasOwnProperty('minerData')) {
            if (res.hasOwnProperty('deadline') &&
                req.minerData.hasOwnProperty('accountId')) {
    
                var deadline = parseInt(res.deadline);
                var accountId = req.minerData.accountId;
                process.nextTick(function(){
                    req.minerData.deadline = deadline;
                    req.minerData.submission = res.result;
    
                    poolShare.updateByNewDeadline(accountId,deadline);
    
                    var accountShare = poolShare.getAccountShare(accountId);
                    if(accountShare != null){
                        poolProtocol.getWebsocket().emit('roundShares',JSON.stringify(accountShare));
                    }
    
                    var sessionState = poolSession.getState();
    
                    var currentTime = new Date().getTime();
                    var miningInfo = {
                        height      : sessionState.current.blockHeight,
                        currentTime : currentTime,
                        totalShare  : sessionState.current.totalShare,
                        submitters  : sessionState.current.submitters,
                        roundStart  : sessionState.current.startTime,
                        netDiff     : poolSession.getNetDiff(),
                        bestDeadline: sessionState.current.bestDeadline
                    };
    
                    if(sessionState.current.bestDeadline > deadline){
                        sessionState.current.bestDeadline = deadline;
                        console.log('new best deadline '+sessionState.current.bestDeadline);
                        poolProtocol.getWebsocket().emit('miningInfo',JSON.stringify(miningInfo));
    				  var minerPic ='<img src="Hopstarter-Button-Button-Help.ico" alt="'+req.minerData.xMiner+'" style="width:20px;height:20px;">';
    					if(req.minerData.xMiner.toString().startsWith('Blago'))
    					{
    				   minerPic = '<img src="Untitled-1.png" alt="'+req.minerData.xMiner+'" style="width:20px;height:20px;">'
    					} else if(req.minerData.xMiner.toString().startsWith('IBAndroid'))
    					 {
    					minerPic = '<img src="http://storage.googleapis.com/ix_choosemuse/uploads/2016/02/android-logo.png" alt="'+req.minerData.xMiner+' " style="width:20px;height:20px;">'
    					 }
    					 else if(req.minerData.xMiner.toString().startsWith('burstcoin-jminer'))
    					  {
    					 minerPic = '<img src="Jminer.png" alt="'+req.minerData.xMiner+' " style="width:20px;height:20px;">'
    					  }
    					  else if(req.minerData.xMiner.toString().startsWith('creepsky'))
    					  {
    					 minerPic = '<img src="cat_tied.png" alt="'+req.minerData.xMiner+' " style="width:20px;height:20px;">'
    					  }
                     //   poolProtocol.clientLog("new best deadline : #"+poolSession.getCurrentBlockHeight());
                           poolProtocol.clientLogFormatted('<span class="logLine time">'+getDateTime()+'</span>'+minerPic+'<span class="logLine"> Best deadline = </span><span class="logLine deadline">'+moment.duration(req.minerData.deadline*1000).humanize(false)+'</span><span class="logLine"> by Burst ID: </span><span class="logLine accountName"><a href="https://block.burstcoin.info/acc.php?acc='+req.minerData.accountId+'" target=_blank>'+req.minerData.accountId+'</a></span>');
               
                    }
                    if(sessionState.current.bestDeadline == -1){
                        sessionState.current.bestDeadline = deadline;
                        console.log('new best deadline '+sessionState.current.bestDeadline);
                        poolProtocol.getWebsocket().emit('miningInfo',JSON.stringify(miningInfo));
    					var minerPic ='<img src="Hopstarter-Button-Button-Help.ico" alt="'+req.minerData.xMiner+'" style="width:20px;height:20px;">';
    							if(req.minerData.xMiner.toString().startsWith('Blago'))
    							{
    						   minerPic = '<img src="Untitled-1.png" alt="'+req.minerData.xMiner+'" style="width:20px;height:20px;">'
    							} else if(req.minerData.xMiner.toString().startsWith('IBAndroid'))
    							 {
    							minerPic = '<img src="http://storage.googleapis.com/ix_choosemuse/uploads/2016/02/android-logo.png" alt="'+req.minerData.xMiner+' " style="width:20px;height:20px;">'
    							 }
    							 else if(req.minerData.xMiner.toString().startsWith('burstcoin-jminer'))
    							  {
    							 minerPic = '<img src="Jminer.png" alt="'+req.minerData.xMiner+' " style="width:20px;height:20px;">'
    							  }
                        //poolProtocol.clientLog("new best deadline : #"+poolSession.getCurrentBlockHeight());
                       poolProtocol.clientLogFormatted('<span class="logLine time">'+getDateTime()+'</span>'+minerPic+'<span class="logLine"> Best deadline = </span><span class="logLine deadline">'+moment.duration(req.minerData.deadline*1000).humanize(false)+'</span><span class="logLine"> by Burst ID: </span><span class="logLine accountName"><a href="https://block.burstcoin.info/acc.php?acc='+req.minerData.accountId+'" target=_blank>'+req.minerData.accountId+'</a></span>');
               
                    }
                });
            }
        }
    }
    
    
    function onMiningInfoUpdate(res){
    
        var miningInfo = res;
    
        if(poolSession.getCurrentBlockHeight() < miningInfo.height){
            onNewBlock(miningInfo);
        }
    }
    
    function onNewClientConnected(socket){
        var clientIp   = socket.request.connection.remoteAddress;
        var clientPort = socket.request.connection.remotePort;
    
        socket.on('chat', function(msg){
            onWebsocketClientChat(clientIp,msg);
        });
    
        socket.on('disconnect', function() {
            //console.log('viewer disconnected from '+clientIp+":"+clientPort);
        });
    
        //socket.emit('log','<div class=".json-text>">Welcome to BurstPool, may the hash be with you!</div>');
        //poolProtocol.clientLog('viewer connected from '+clientIp+":"+clientPort);
        //console.log('viewer connected from '+clientIp+":"+clientPort);
        var cumulativeShare = poolShare.getCumulativeShares();
        socket.emit('shareList',JSON.stringify(cumulativeShare));
        socket.emit('sentList',JSON.stringify(poolPayment.getPaidList()));
        socket.emit('blockHistory',JSON.stringify(poolSession.getState().prevBlocks));
        logMiningRound(socket);
    }
    
    function onWebsocketClientChat(clientIp, msg){
        var textMsg = msg;
        if(textMsg.length > 256){
            textMsg = textMsg.substring(0, 255);
        }
        poolProtocol.clientLog(clientIp+' : '+'<span class="chatMsg">'+textMsg+'</span>');
    }
    
    function saveSession(){
        poolShare.saveSession();
        poolPayment.saveSession();
        poolSession.saveSession();
        logMiningRound();
    }
    
    function initPool(walletNdx){
        poolSession.setWalletNdx(walletNdx);
        poolSession.init(function(){
            async.parallel(
                [
                    function(callback){
                        poolPayment.loadSession(function(){
                            callback();
                        })
                    },
                    function(callback){
                        poolShare.loadSession(function(){
                            callback();
                        });
                    }
                ],
                function(err, results){
                    poolProtocol.start(onNonceSubmitReq,onNonceSubmitedRes,onNewClientConnected);
                    setInterval(saveSession,60000);
                    setInterval(function(){
                        poolSession.getMiningInfo(function(result){
                            if(result.status === true){
                                onMiningInfoUpdate(result.msg);
                            }
                        });
                    },1000);
                }
            );
        });
    }
    
    initPool(config.walletIndex);
    
    process.stdin.resume();
    
    function exitHandler(options, err) {
        poolShare.saveSession();
        if (options.cleanup) console.log('clean');
        if (err) console.log(err.stack);
        if (options.exit) process.exit();
    }
    
    process.on('exit', exitHandler.bind(null,{cleanup:true}));
    process.on('SIGINT', exitHandler.bind(null, {exit:true}));
    process.on('uncaughtException', exitHandler.bind(null, {exit:true}));
    

    Pool's console

    genesis base target = 18325193796
    current timestamp 1486935219600
    genesis-block blocktime 79212820
    genesis-block timestamp 1407722399600
    burst pool running on port 8124
    websocket running on port 4443
    http server running on port 8020
    new best deadline 1359691053
    TypeError: Object burstcoin-jminer-0.4.5-RELEASE has no method 'startsWith'
        at /var/www/burstcoin_ml/pool/burst-pool.js:199:43
        at process._tickCallback (node.js:415:13)
    clean
    
    


  • @Lexicon Now running v6.9.5 LTS

    genesis base target = 18325193796
    current timestamp 1486936771374
    genesis-block blocktime 79214371
    genesis-block timestamp 1407722400374
    burst pool running on port 8124
    websocket running on port 4443
    http server running on port 8020
    TypeError: minerReq.query.hasOwnProperty is not a function
        at onNonceSubmitReq (/var/www/burstcoin_ml/pool/burst-pool.js:96:24)
        at transformRequest (/var/www/burstcoin_ml/pool/burst-pool-protocol.js:84:5)
        at Server.<anonymous> (/var/www/burstcoin_ml/pool/burst-pool-protocol.js:136:9)
        at emitTwo (events.js:106:13)
        at Server.emit (events.js:191:7)
        at HTTPParser.parserOnIncoming [as onIncoming] (_http_server.js:546:12)
        at HTTPParser.parserOnHeadersComplete (_http_common.js:99:23)
    clean
    


  • @Tate-A said in Lex Pool (A rewritten pool based on uray source):

    query.hasOwnProperty is not a function

    changing everywhere where it uses minerReq.query.hasOwnProperty to

    Object.prototype.hasOwnProperty.call(minerReq.query, 'whatever') 
    

    fix's those errors

    you will find another error around the done() callback probably when a block is won. lmk what like it is and ill get you my fix.

    i think a few of them i used a try catch statement. they remove some callback support in one of the updates from 5.12 up to v6



  • @Lexicon Okay, it looks like it's a go. Thanks @Lexicon and @Burstde for your help! :-)



  • @Lexicon Sorry for bugging you again man, I must be dumb, it seems to be running fine. except for it is not updating the site, I have no errors. I'm currently run node js v4.7.3.



  • @Tate-A I got it, like I said i'm dumb. All I had to do was rename: Chart.js to chart.js Sending you some burst for you help, BURST-ZPPL-BV2U-VVZN-8DJX7.



  • @Tate-A haha this is a common one XD

    apparently windows doesnt care about the case of charts.js but linux does.

    linux only likes it lowercase. and i think windows doesn't care and will run with either.



  • @Lexicon Hey, any chance u could assist me step by step on how can I create my own pool in my VPS linux based server?

    The START POOL.cmd file is not present in the download file neither.



  • This post is deleted!


  • @pr0cesor hi buddy ive been away from this thread for a while however if you follow the guide above it should get you started on setting up.



  • @Lexicon That's sad m8, pissing me off reading something like this. Did u contact the webmaster of the pool? Is there anything we can do to shut it down or at least to force him giving u credit instead of stealing ur work?



  • This post is deleted!


  • This post is deleted!


  • @Lexicon Yeah I saw it, why don't u make an announcement in return about the pool and the code he is using. His pool does not deserve miners if he does not know what honesty means.



  • @Lexicon hi, been running your pool code locally, i cannot seem to understand the payouts,
    from what i can gather, the pool is treated like another miner?
    a block is found, miners get paid,pool gets paid and yet an amount is retained in pool account. Could you shed any light on this.



  • @iKnow0 the pool keeps a threshold for each user to save on tx fee's that could be what your seeing. also rounding tends to leave a bit over as well.



  • @Lexicon where can i set the threshold in the config or is it hard coded?



  • @iKnow0 If you are using the Lex's their is only one line to worry about.

    cumulativeFundReduction : 0.5,

    Lower than .5 will give more to the reward finder. Then to the miners. These pools are designed to pay every miner once they reach their threshold. Again pay happens when a block is found. More blocks more miner get paid.
    TX fee is included with reward and is shown on the pool console. this one might be different but gives you and idea. Everyone get a share of that block.
    0_1488654083580_upload-98daed97-7528-4327-b933-6ec6b62dd7b5


Log in to reply
 

Looks like your connection to Burst - Efficient HDD Mining was lost, please wait while we try to reconnect.