@@ -51,7 +51,7 @@ protected byte[] SerializeHeader(Span<byte> coinbaseHash)
5151 return blockHeader . ToBytes ( ) ;
5252 }
5353
54- protected virtual ( Share Share , string BlockHex ) ProcessShareInternal ( ILogger logger ,
54+ public virtual ( Share Share , string BlockHex ) ProcessShareInternal ( ILogger logger ,
5555 StratumConnection worker , ulong nonce , string inputHeaderHash , string mixHash )
5656 {
5757 var context = worker . ContextAs < RavencoinWorkerContext > ( ) ;
@@ -72,13 +72,14 @@ protected virtual (Share Share, string BlockHex) ProcessShareInternal(ILogger lo
7272 var headerHashHex = headerHash . ToHexString ( ) ;
7373
7474 if ( headerHashHex != inputHeaderHash )
75- {
76- throw new StratumException ( StratumError . MinusOne , "bad header-hash" ) ;
77- }
75+ throw new StratumException ( StratumError . MinusOne , $ "bad header-hash") ;
7876
7977 if ( ! kawpowHasher . Compute ( logger , ( int ) BlockTemplate . Height , headerHash . ToArray ( ) , nonce , out var mixHashOut , out var resultBytes ) )
8078 throw new StratumException ( StratumError . MinusOne , "bad hash" ) ;
8179
80+ if ( mixHash != mixHashOut . ToHexString ( ) )
81+ throw new StratumException ( StratumError . MinusOne , $ "bad mix-hash") ;
82+
8283 resultBytes . ReverseInPlace ( ) ;
8384 mixHashOut . ReverseInPlace ( ) ;
8485
@@ -247,7 +248,7 @@ protected virtual string CreateHeaderHash(RavencoinWorkerJob workerJob)
247248 var coinbaseHasher = coin . CoinbaseHasherValue ;
248249 var extraNonce1 = workerJob . ExtraNonce1 ;
249250
250- var coinbase = SerializeCoinbase ( workerJob . ExtraNonce1 ) ;
251+ var coinbase = SerializeCoinbase ( extraNonce1 ) ;
251252 Span < byte > coinbaseHash = stackalloc byte [ 32 ] ;
252253 coinbaseHasher . Digest ( coinbase , coinbaseHash ) ;
253254
@@ -259,29 +260,6 @@ protected virtual string CreateHeaderHash(RavencoinWorkerJob workerJob)
259260 return headerHash . ToHexString ( ) ;
260261 }
261262
262- public virtual ( Share Share , string BlockHex ) ProcessShare ( ILogger logger , StratumConnection worker , string nonce , string headerHash , string mixHash )
263- {
264- Contract . RequiresNonNull ( worker ) ;
265- Contract . Requires < ArgumentException > ( ! string . IsNullOrEmpty ( nonce ) ) ;
266-
267- var context = worker . ContextAs < RavencoinWorkerContext > ( ) ;
268-
269- // mixHash
270- if ( mixHash . Length != 64 )
271- throw new StratumException ( StratumError . Other , $ "incorrect size of mixHash: { mixHash } ") ;
272-
273- // validate nonce
274- if ( nonce . Length != 16 )
275- throw new StratumException ( StratumError . Other , $ "incorrect size of nonce: { nonce } ") ;
276-
277- // check if nonce is within range
278- if ( nonce . IndexOf ( context . ExtraNonce1 . Substring ( 0 , 4 ) ) != 0 )
279- throw new StratumException ( StratumError . Other , $ "nonce out of range: { nonce } ") ;
280-
281- var nonceLong = ulong . Parse ( nonce , NumberStyles . HexNumber ) ;
282-
283- return ProcessShareInternal ( logger , worker , nonceLong , headerHash , mixHash ) ;
284- }
285263
286264 #endregion // API-Surface
287265}
0 commit comments