@@ -9,75 +9,75 @@ var LogB = global.logger.LogB;
99
1010module . exports = class RPCServer extends EventEmitter {
1111
12- constructor ( config ) {
12+ constructor ( config ) {
1313 super ( ) ;
14- var _this = this ;
15-
16- this . minerEthAddress = config . Miner . EthAddress . toLowerCase ( ) ;
17- this . mintingAccount = "" ;
18- this . minerVarDiff = 0 ;
19- this . minimumShareTarget = "" ;
20- this . challengeNumber = "" ;
21-
22- LogB ( 'JSON-RPC server listening on localhost:' + config . RPC . Port ) ;
23-
24- // create an rpc server
25- var server = jayson . server ( {
26-
27- getPoolEthAddress : function ( args , callback ) {
28- // LogB('getPoolEthAddress: ', args);
29- callback ( null , _this . mintingAccount ) ;
30- } ,
31-
32- getMinimumShareDifficulty : async function ( args , callback ) {
33- // LogB('getMinimumShareDifficulty: ', args);
34- if ( args [ 0 ] . toLowerCase ( ) != _this . minerEthAddress ) {
35- callback ( { code : - 1 , message : 'Invalid minerEthAddresss ' + args [ 0 ] + '. Expecting ' + _this . minerEthAddress } ) ;
36- }
37- callback ( null , _this . minerVarDiff ) ;
38- } ,
39-
40- getMinimumShareTarget : async function ( args , callback ) {
41- // LogB('getMinimumShareTarget: ', args);
42- if ( args [ 0 ] . toLowerCase ( ) != _this . minerEthAddress ) {
43- callback ( { code : - 1 , message : 'Invalid minerEthAddresss ' + args [ 0 ] + '. Expecting ' + _this . minerEthAddress } ) ;
44- }
45- callback ( null , _this . minimumShareTarget ) ;
46- } ,
47-
48- getChallengeNumber : async function ( args , callback ) {
49- // LogB('getChallengeNumber: ', args);
50- callback ( null , _this . challengeNumber ) ;
51- } ,
52-
53- submitShare : async function ( args , callback ) {
54- // LogB('submitShare: ', args);
55-
56- // notify interested listeners of a share submit. provide a callback so we can be
57- // notified if share was accepted (true/false).
58- _this . emit ( 'submitShare' , args , ( res ) => {
59- callback ( null , res ) ;
60- } )
61- } ,
62-
63- } ) ;
64-
65- server . http ( ) . listen ( config . RPC . Port ) ;
66- }
67-
68-
69- setWork ( params ) {
70- try {
71- this . challengeNumber = params [ 0 ] ;
72- this . minimumShareTarget = params [ 1 ] ;
73- this . minerVarDiff = params [ 2 ] ;
74- this . mintingAccount = params [ 3 ] ;
75- }
76- catch ( err ) {
77- LogB ( 'Error in setWork: unable to process mining pool work parameters' ) ;
78- LogB ( 'params=' , params ) ;
79- }
80- }
81-
14+ var _this = this ;
15+
16+ this . minerEthAddress = config . Miner . EthAddress . toLowerCase ( ) ;
17+ this . mintingAccount = "" ;
18+ this . minerVarDiff = 0 ;
19+ this . minimumShareTarget = "" ;
20+ this . challengeNumber = "" ;
21+
22+ LogB ( 'JSON-RPC server listening on localhost:' + config . RPC . Port ) ;
23+
24+ // create an rpc server
25+ var server = jayson . server ( {
26+
27+ getPoolEthAddress : function ( args , callback ) {
28+ // LogB('getPoolEthAddress: ', args);
29+ callback ( null , _this . mintingAccount ) ;
30+ } ,
31+
32+ getMinimumShareDifficulty : async function ( args , callback ) {
33+ // LogB('getMinimumShareDifficulty: ', args);
34+ if ( args [ 0 ] . toLowerCase ( ) != _this . minerEthAddress ) {
35+ callback ( { code : - 1 , message : 'Invalid minerEthAddresss ' + args [ 0 ] + '. Expecting ' + _this . minerEthAddress } ) ;
36+ }
37+ callback ( null , _this . minerVarDiff ) ;
38+ } ,
39+
40+ getMinimumShareTarget : async function ( args , callback ) {
41+ // LogB('getMinimumShareTarget: ', args);
42+ if ( args [ 0 ] . toLowerCase ( ) != _this . minerEthAddress ) {
43+ callback ( { code : - 1 , message : 'Invalid minerEthAddresss ' + args [ 0 ] + '. Expecting ' + _this . minerEthAddress } ) ;
44+ }
45+ callback ( null , _this . minimumShareTarget ) ;
46+ } ,
47+
48+ getChallengeNumber : async function ( args , callback ) {
49+ // LogB('getChallengeNumber: ', args);
50+ callback ( null , _this . challengeNumber ) ;
51+ } ,
52+
53+ submitShare : async function ( args , callback ) {
54+ // LogB('submitShare: ', args);
55+
56+ // notify interested listeners of a share submit. provide a callback so we can be
57+ // notified if share was accepted (true/false).
58+ _this . emit ( 'submitShare' , args , ( res ) => {
59+ callback ( null , res ) ;
60+ } )
61+ } ,
62+
63+ } ) ;
64+
65+ server . http ( ) . listen ( config . RPC . Port ) ;
66+ }
67+
68+
69+ setWork ( params ) {
70+ try {
71+ this . challengeNumber = params [ 0 ] ;
72+ this . minimumShareTarget = params [ 1 ] ;
73+ this . minerVarDiff = params [ 2 ] ;
74+ this . mintingAccount = params [ 3 ] ;
75+ }
76+ catch ( err ) {
77+ LogB ( 'Error in setWork: unable to process mining pool work parameters' ) ;
78+ LogB ( 'params=' , params ) ;
79+ }
80+ }
81+
8282}
8383
0 commit comments