zone117x / node-stratum-pool

High performance Stratum poolserver in Node.js
GNU General Public License v2.0
418 stars 851 forks source link

This..... dosent work. #169

Open ghost opened 5 years ago

ghost commented 5 years ago

        _this.stratumServer = new stratum.Server(options, authorizeFn);

        _this.stratumServer.on('started', function(){
            options.initStats.stratumPorts = Object.keys(options.ports);
            _this.stratumServer.broadcastMiningJobs(_this.jobManager.currentJob.getJobParams());
            finishedCallback();

        }).on('broadcastTimeout', function(){
            emitLog('No new blocks for ' + options.jobRebroadcastTimeout + ' seconds - updating transactions & rebroadcasting work');

            **GetBlockTemplate(function(error, rpcData, processedBlock){
                if (error || processedBlock) return;
                _this.jobManager.updateCurrentJob(rpcData);**
            });```
ghost commented 5 years ago

jobRebroadcastTimeout does not update correctly the mining difficulty if the mining difficulty in THE SAME BLOCK changes with time.

ghost commented 5 years ago

so if the mining difficulty is adjusted with time, like in some adjusted darkgravitywave algorithm that scale difficulty down with TIME ( for example, progressively lower difficulty if there is a long stale tip..... ) ..... the pool dosent brodcast that info, and the miners keeps trying to mine a higher difficulty block, and if a block is found, the difficulty bits dosent match the pow difficulty bits.

ghost commented 5 years ago

When a new block is found, the pool sends a new getblocktemplate and checks the new difficulty for the next block. jobrebrodcast timeout should also do this.

Or a new option could be added for coins that changes difficulty in the same block over time.

ghost commented 5 years ago

.on('broadcastTimeout', function(){ emitLog('No new blocks for ' + options.jobRebroadcastTimeout + ' seconds - updating transactions & rebroadcasting work');

        GetBlockTemplate(function(error, rpcData, processedBlock){
     emitLog('This is the value of rpcData : ', rpcdata);
     emitLog('Its supposed to return if there is an error or a processedBlock ....  will it return ?');
            if (error || processedBlock) return;
     emitLog('no, did not return...');
            _this.jobManager.updateCurrentJob(rpcData);
    emitLog('sent updateCurrentJob(rpcdata) to jobManager');
        });
ghost commented 5 years ago

RESULT :

2019-03-09 12:38:56 [Pool] [lightningcash gold] (Thread 8) No new blocks for 30 seconds - updating transactions & rebroadcasting work /home/merlin/nomp/node_modules/stratum-pool/lib/pool.js:476 emitLog('This is the value of rpcData : ', rpcdata); ^

ReferenceError: rpcdata is not defined at /home/merlin/nomp/node_modules/stratum-pool/lib/pool.js:476:46 at /home/merlin/nomp/node_modules/stratum-pool/lib/pool.js:592:21 at itemFinished (/home/merlin/nomp/node_modules/stratum-pool/lib/daemon.js:156:36) at /home/merlin/nomp/node_modules/stratum-pool/lib/daemon.js:169:17 at parseJson (/home/merlin/nomp/node_modules/stratum-pool/lib/daemon.js:85:17) at IncomingMessage. (/home/merlin/nomp/node_modules/stratum-pool/lib/daemon.js:95:17) at emitNone (events.js:111:20) at IncomingMessage.emit (events.js:208:7) at endReadableNT (_stream_readable.js:1064:12) at _combinedTickCallback (internal/process/next_tick.js:138:11) 2019-03-09 12:38:56 [Master] [PoolSpawner] Fork 7 died, spawning replacement worker...

ghost commented 5 years ago

Further debugging gives this :

2019-03-09 13:02:32 [Pool] [lightningcash gold] (Thread 5) No new blocks for 30 seconds - updating transactions & rebroadcasting work
2019-03-09 13:02:32 [Pool] [lightningcash gold] (Thread 5) Its supposed to return if there is an error or a processedBlock .... will it return ? 2019-03-09 13:02:32 [Pool] [lightningcash gold] (Thread 5) no, did not return... ( normal here.... ) 2019-03-09 13:02:32 [Pool] [lightningcash gold] (Thread 5) This is the value of result : (empty ???) 2019-03-09 13:02:32 [Pool] [lightningcash gold] (Thread 5) sent updateCurrentJob(result) to jobManager