@@ -71,7 +71,7 @@ protected virtual async Task OnHelloAsync(StratumConnection connection, Timestam
71
71
// [Respect the goddamn standards Nicehack :(]
72
72
var response = new JsonRpcResponse < object [ ] > ( data , request . Id ) ;
73
73
74
- if ( context . IsNicehash )
74
+ if ( context . IsNicehash || manager . ValidateIsGoldShell ( context . UserAgent ) || manager . ValidateIsIceRiverMiner ( context . UserAgent ) )
75
75
{
76
76
response . Extra = new Dictionary < string , object > ( ) ;
77
77
response . Extra [ "error" ] = null ;
@@ -105,7 +105,7 @@ protected virtual async Task OnSubscribeAsync(StratumConnection connection, Time
105
105
// [Respect the goddamn standards Nicehack :(]
106
106
var response = new JsonRpcResponse < object > ( connection . ConnectionId , request . Id ) ;
107
107
108
- if ( context . IsNicehash )
108
+ if ( context . IsNicehash || manager . ValidateIsGoldShell ( context . UserAgent ) || manager . ValidateIsIceRiverMiner ( context . UserAgent ) )
109
109
{
110
110
response . Extra = new Dictionary < string , object > ( ) ;
111
111
response . Extra [ "error" ] = null ;
@@ -156,7 +156,7 @@ protected virtual async Task OnAuthorizeAsync(StratumConnection connection, Time
156
156
// [Respect the goddamn standards Nicehack :(]
157
157
var response = new JsonRpcResponse < object > ( context . IsAuthorized , request . Id ) ;
158
158
159
- if ( context . IsNicehash )
159
+ if ( context . IsNicehash || manager . ValidateIsGoldShell ( context . UserAgent ) || manager . ValidateIsIceRiverMiner ( context . UserAgent ) )
160
160
{
161
161
response . Extra = new Dictionary < string , object > ( ) ;
162
162
response . Extra [ "error" ] = null ;
@@ -200,7 +200,10 @@ protected virtual async Task OnAuthorizeAsync(StratumConnection connection, Time
200
200
201
201
logger . Info ( ( ) => $ "[{ connection . ConnectionId } ] Setting static difficulty of { staticDiff . Value } ") ;
202
202
}
203
-
203
+
204
+ // send initial difficulty
205
+ await connection . NotifyAsync ( AlephiumStratumMethods . SetDifficulty , new object [ ] { context . Difficulty } ) ;
206
+
204
207
// send intial job
205
208
await SendJob ( connection , context , currentJobParams ) ;
206
209
}
@@ -259,7 +262,7 @@ protected virtual async Task OnSubmitAsync(StratumConnection connection, Timesta
259
262
// [Respect the goddamn standards Nicehack :(]
260
263
var response = new JsonRpcResponse < object > ( true , request . Id ) ;
261
264
262
- if ( context . IsNicehash )
265
+ if ( context . IsNicehash || manager . ValidateIsGoldShell ( context . UserAgent ) || manager . ValidateIsIceRiverMiner ( context . UserAgent ) )
263
266
{
264
267
response . Extra = new Dictionary < string , object > ( ) ;
265
268
response . Extra [ "error" ] = null ;
@@ -311,15 +314,19 @@ protected virtual async Task OnNewJobAsync(AlephiumJobParams jobParams)
311
314
await Guard ( ( ) => ForEachMinerAsync ( async ( connection , ct ) =>
312
315
{
313
316
var context = connection . ContextAs < AlephiumWorkerContext > ( ) ;
314
-
317
+
318
+ // varDiff: if the client has a pending difficulty change, apply it now
319
+ if ( context . ApplyPendingDifficulty ( ) )
320
+ await connection . NotifyAsync ( AlephiumStratumMethods . SetDifficulty , new object [ ] { context . Difficulty } ) ;
321
+
315
322
await SendJob ( connection , context , currentJobParams ) ;
316
323
} ) ) ;
317
324
}
318
325
319
326
private async Task SendJob ( StratumConnection connection , AlephiumWorkerContext context , AlephiumJobParams jobParams )
320
327
{
321
328
var target = EncodeTarget ( context . Difficulty ) ;
322
-
329
+
323
330
// clone job params
324
331
var jobParamsActual = new AlephiumJobParams
325
332
{
@@ -330,10 +337,7 @@ private async Task SendJob(StratumConnection connection, AlephiumWorkerContext c
330
337
TxsBlob = jobParams . TxsBlob ,
331
338
TargetBlob = target ,
332
339
} ;
333
-
334
- // send difficulty
335
- await connection . NotifyAsync ( AlephiumStratumMethods . SetDifficulty , new object [ ] { context . Difficulty } ) ;
336
-
340
+
337
341
// send job
338
342
await connection . NotifyAsync ( AlephiumStratumMethods . MiningNotify , new object [ ] { jobParamsActual } ) ;
339
343
}
@@ -480,6 +484,9 @@ protected override async Task OnVarDiffUpdateAsync(StratumConnection connection,
480
484
481
485
if ( context . ApplyPendingDifficulty ( ) )
482
486
{
487
+ // send difficulty
488
+ await connection . NotifyAsync ( AlephiumStratumMethods . SetDifficulty , new object [ ] { context . Difficulty } ) ;
489
+
483
490
// send job
484
491
await SendJob ( connection , context , currentJobParams ) ;
485
492
}
0 commit comments