@@ -24,19 +24,26 @@ module.exports = class RPCServer extends EventEmitter {
24
24
this . lastRPCRequest = Date . now ( ) ;
25
25
this . activeMiner = true ;
26
26
this . poolConnection = false ;
27
+ this . poolError = null ;
27
28
28
29
// create an rpc server
29
30
var server = jayson . server ( {
30
31
31
32
getPoolEthAddress : ( args , callback ) => {
32
33
this . serviceRPCRequest ( 'getPoolEthAddress' , ( ) => {
33
- callback ( null , this . mintingAccount ) ;
34
+ if ( this . poolError ) {
35
+ callback ( this . poolError ) ;
36
+ } else {
37
+ callback ( null , this . mintingAccount ) ;
38
+ }
34
39
} ) ;
35
40
} ,
36
41
37
42
getMinimumShareDifficulty : async ( args , callback ) => {
38
43
this . serviceRPCRequest ( 'getMinimumShareDifficulty' , ( ) => {
39
- if ( args [ 0 ] . toLowerCase ( ) != this . minerEthAddress ) {
44
+ if ( this . poolError ) {
45
+ callback ( this . poolError ) ;
46
+ } else if ( args [ 0 ] . toLowerCase ( ) != this . minerEthAddress ) {
40
47
callback ( { code : - 1 , message : 'Invalid minerEthAddresss ' + args [ 0 ] + '. Expecting ' + this . minerEthAddress } ) ;
41
48
} else {
42
49
callback ( null , this . minerVarDiff ) ;
@@ -46,7 +53,9 @@ module.exports = class RPCServer extends EventEmitter {
46
53
47
54
getMinimumShareTarget : async ( args , callback ) => {
48
55
this . serviceRPCRequest ( 'getMinimumShareTarget' , ( ) => {
49
- if ( args [ 0 ] . toLowerCase ( ) != this . minerEthAddress ) {
56
+ if ( this . poolError ) {
57
+ callback ( this . poolError ) ;
58
+ } else if ( args [ 0 ] . toLowerCase ( ) != this . minerEthAddress ) {
50
59
callback ( { code : - 1 , message : 'Invalid minerEthAddresss ' + args [ 0 ] + '. Expecting ' + this . minerEthAddress } ) ;
51
60
} else {
52
61
callback ( null , this . minimumShareTarget ) ;
@@ -56,17 +65,25 @@ module.exports = class RPCServer extends EventEmitter {
56
65
57
66
getChallengeNumber : async ( args , callback ) => {
58
67
this . serviceRPCRequest ( 'getChallengeNumber' , ( ) => {
59
- callback ( null , this . challengeNumber ) ;
68
+ if ( this . poolError ) {
69
+ callback ( this . poolError ) ;
70
+ } else {
71
+ callback ( null , this . challengeNumber ) ;
72
+ }
60
73
} ) ;
61
74
} ,
62
75
63
76
submitShare : async ( args , callback ) => {
64
77
this . serviceRPCRequest ( 'submitShare' , ( ) => {
65
- // notify interested listeners of a share submit. provide a callback so we can be
66
- // notified if share was accepted (true/false).
67
- this . emit ( 'submitShare' , args , ( res ) => {
68
- callback ( null , res ) ;
69
- } )
78
+ if ( this . poolError ) {
79
+ callback ( this . poolError ) ;
80
+ } else {
81
+ // notify interested listeners of a share submit. provide a callback so we can be
82
+ // notified if share was accepted (true/false).
83
+ this . emit ( 'submitShare' , args , ( res ) => {
84
+ callback ( null , res ) ;
85
+ } )
86
+ }
70
87
} ) ;
71
88
} ,
72
89
@@ -131,5 +148,14 @@ module.exports = class RPCServer extends EventEmitter {
131
148
}
132
149
}
133
150
151
+
152
+ poolLoginNotify ( error ) {
153
+ if ( error ) {
154
+ this . poolError = { code : error [ 0 ] , message : error [ 1 ] } ;
155
+ } else {
156
+ this . poolError = null ;
157
+ }
158
+ }
159
+
134
160
}
135
161
0 commit comments