private void HandleInvalidShare(IShare share) { var miner = (IStratumMiner)share.Miner; if (miner.Username.Equals(share.PayoutUser) && share.Error != ShareError.InsideSleepWindow) { miner.InvalidShareCount++; } JsonRpcException exception = null; // the exception determined by the stratum error code. switch (share.Error) { case ShareError.DuplicateShare: exception = new DuplicateShareError(share.Nonce); break; case ShareError.IncorrectExtraNonce2Size: exception = new OtherError("Incorrect extranonce2 size"); break; case ShareError.IncorrectNTimeSize: exception = new OtherError("Incorrect nTime size"); break; case ShareError.IncorrectNonceSize: exception = new OtherError("Incorrect nonce size"); break; case ShareError.JobNotFound: exception = new JobNotFoundError(share.JobId); break; case ShareError.LowDifficultyShare: exception = new LowDifficultyShare(share.Difficulty); break; case ShareError.NTimeOutOfRange: exception = new OtherError("nTime out of range"); break; case ShareError.InsideSleepWindow: exception = new OtherError("Inside Sleep Window"); break; } JsonRpcContext.SetException(exception); // set the stratum exception within the json-rpc reply. Debug.Assert(exception != null); // exception should be never null when the share is marked as invalid. if (share.Error == ShareError.InsideSleepWindow) { if (DateTime.Now.Millisecond % 1000 == 0) { _logger.Debug("Rejected share by miner {0:l}, reason: {1:l}", share.PayoutUser, exception.message); } } else { _logger.Debug("Rejected share by miner {0:l}, reason: {1:l}", share.PayoutUser, exception.message); } }
/// <summary> /// Authenticates the miner. /// </summary> /// <param name="user"></param> /// <param name="password"></param> /// <returns></returns> public bool Authenticate(string user, string password) { Username = user; /*string magicToken = computeMagicToken(user, this.ExtraNonce.ToString()); * * if (password == null || magicToken == null || !password.Equals(magicToken)) * { * Authenticated = false; * * _logger.Debug( * this.Authenticated ? "Authenticated miner: {0:l} [{1:l}]" : "Miner authentication failed: {0:l} [{1:l}]", * this.Username, ((IClient)this).Connection.RemoteEndPoint); * * return Authenticated; * }*/ _minerManager.Authenticate(this); if (!Authenticated) { JsonRpcContext.SetException(new AuthenticationError(Username)); } return(Authenticated); }
/// <summary> /// Authenticates the miner. /// </summary> /// <param name="user"></param> /// <param name="password"></param> /// <returns></returns> public bool Authenticate(string user, string password) { Username = user; _minerManager.Authenticate(this); if (!Authenticated) { JsonRpcContext.SetException(new AuthenticationError(Username)); } return(Authenticated); }
/// <summary> /// Authenticates the miner. /// </summary> /// <param name="user"></param> /// <param name="password"></param> /// <returns></returns> public bool Authenticate(string user, string password) { Username = user.Trim('@'); // update username with the one checked in Authenticate method Username = _minerManager.Authenticate(this); if (!Authenticated) { JsonRpcContext.SetException(new AuthenticationError(Username)); } return(Authenticated); }
private void HandleInvalidShare(IShare share) { var miner = (IStratumMiner)share.Miner; miner.InvalidShares++; JsonRpcException exception = null; // the exception determined by the stratum error code. switch (share.Error) { case ShareError.DuplicateShare: exception = new DuplicateShareError(share.Nonce); break; case ShareError.IncorrectExtraNonce2Size: exception = new OtherError("Incorrect extranonce2 size"); break; case ShareError.IncorrectNTimeSize: exception = new OtherError("Incorrect nTime size"); break; case ShareError.IncorrectNonceSize: exception = new OtherError("Incorrect nonce size"); break; case ShareError.JobNotFound: exception = new JobNotFoundError(share.JobId); break; case ShareError.LowDifficultyShare: exception = new LowDifficultyShare(share.Difficulty); break; case ShareError.NTimeOutOfRange: exception = new OtherError("nTime out of range"); break; } JsonRpcContext.SetException(exception); // set the stratum exception within the json-rpc reply. Debug.Assert(exception != null); // exception should be never null when the share is marked as invalid. _logger.Debug("Rejected share by miner {0:l}, reason: {1:l}", miner.Username, exception.message); }
private void HandleInvalidShare(IShare share) { var miner = (IStratumMiner)share.Miner; if (share.Error != ShareError.NegativeDifficultyShareOutdatedMiner) { miner.InvalidShareCount++; } else { _logger.Debug("Got negative share from merit-miner 0.1.0 miner. Skipping"); } JsonRpcException exception = null; // the exception determined by the stratum error code. switch (share.Error) { case ShareError.DuplicateShare: exception = new DuplicateShareError(share.Nonce); break; case ShareError.IncorrectExtraNonce2Size: exception = new OtherError("Incorrect extranonce2 size"); break; case ShareError.IncorrectNTimeSize: exception = new OtherError("Incorrect nTime size"); break; case ShareError.IncorrectNonceSize: exception = new OtherError("Incorrect nonce size"); break; case ShareError.JobNotFound: exception = new JobNotFoundError(share.JobId); break; case ShareError.NegativeDifficultyShareOutdatedMiner: exception = new OtherError("Negative share: most likely old merit-miner used"); break; case ShareError.NegativeDifficultyShare: exception = new OtherError("Negative share"); break; case ShareError.LowDifficultyShare: exception = new LowDifficultyShare(share.Difficulty); break; case ShareError.NTimeOutOfRange: exception = new OtherError("nTime out of range"); break; case ShareError.IncorrectCycle: exception = new OtherError("Incorrect cycle"); break; } JsonRpcContext.SetException(exception); // set the stratum exception within the json-rpc reply. Debug.Assert(exception != null); // exception should be never null when the share is marked as invalid. _logger.Debug("Rejected share by miner {0:l}, reason: {1:l}", miner.Username, exception.message); }
public string TestPostProcessorSetsException(string inputValue) { JsonRpcContext.SetException(new JsonRpcException(-27001, "This exception was thrown using: JsonRpcContext.SetException()", null)); return(null); }
private string throwsException3(string s) { JsonRpcContext.SetException(new JsonRpcException(-27000, "This exception was thrown using: JsonRpcContext.Current().SetException()", null)); return(s); }