本文整理汇总了C#中MultiMiner.Engine.MinerProcess类的典型用法代码示例。如果您正苦于以下问题:C# MinerProcess类的具体用法?C# MinerProcess怎么用?C# MinerProcess使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MinerProcess类属于MultiMiner.Engine命名空间,在下文中一共展示了MinerProcess类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckAndNotifyFoundBlocks
private void CheckAndNotifyFoundBlocks(MinerProcess minerProcess, long foundBlocks)
{
//started mining but haven't yet assigned mining members
if (miningCoinConfigurations == null)
return;
string coinName = minerProcess.MinerConfiguration.CoinName;
//reference miningCoinConfigurations so that we get access to the mining coins
Engine.Data.Configuration.Coin configuration = miningCoinConfigurations.SingleOrDefault(c => c.CryptoCoin.Name.Equals(coinName, StringComparison.OrdinalIgnoreCase));
if (configuration == null)
return;
if (configuration.NotifyOnBlockFound2 && (foundBlocks > minerProcess.FoundBlocks))
{
minerProcess.FoundBlocks = foundBlocks;
string notificationReason = String.Format("Block(s) found for {0} (block {1})",
coinName, minerProcess.FoundBlocks);
PostNotification(notificationReason, notificationReason, () =>
{
}, ToolTipIcon.Info, "");
}
}
示例2: FlagSuspiciousMiner
private void FlagSuspiciousMiner(MinerProcess minerProcess, DeviceInformation deviceInformation)
{
if (deviceInformation.Status.ToLower().Contains("sick"))
minerProcess.HasSickDevice = true;
if (deviceInformation.Status.ToLower().Contains("dead"))
minerProcess.HasDeadDevice = true;
if (deviceInformation.CurrentHashrate == 0)
minerProcess.HasZeroHashrateDevice = true;
//only check GPUs for subpar hashrate
//ASICs spike too much for this to be reliable there
//don't check average hashrate if using dynamic intensity
if (deviceInformation.Kind.Equals("GPU", StringComparison.OrdinalIgnoreCase) &&
!engineConfiguration.XgminerConfiguration.DesktopMode)
{
//avoid div by 0
if (deviceInformation.AverageHashrate > 0)
{
double performanceRatio = deviceInformation.CurrentHashrate / deviceInformation.AverageHashrate;
if (performanceRatio <= 0.50)
minerProcess.HasPoorPerformingDevice = true;
}
}
if (miningCoinConfigurations == null)
//started mining but haven't yet assigned mining members
//cannot check the following yet
return;
//Work Utility not returned by legacy API miners
if (!minerProcess.Miner.LegacyApi)
{
double effectiveHashrate = WorkUtilityToHashrate(deviceInformation.WorkUtility);
//avoid div by 0
if (deviceInformation.AverageHashrate > 0)
{
double performanceRatio = effectiveHashrate / deviceInformation.AverageHashrate;
if (performanceRatio <= 0.25)
minerProcess.StoppedAcceptingShares = true;
}
}
}
示例3: CheckAndNotifyAcceptedShares
private void CheckAndNotifyAcceptedShares(MinerProcess minerProcess, long acceptedShares)
{
string coinName = minerProcess.MinerConfiguration.CoinName;
//reference miningCoinConfigurations so that we get access to the mining coins
CoinConfiguration configuration = miningCoinConfigurations.Single(c => c.Coin.Name.Equals(coinName, StringComparison.OrdinalIgnoreCase));
if (configuration == null)
return;
if (configuration.NotifyOnShareAccepted && (acceptedShares > minerProcess.AcceptedShares))
{
minerProcess.AcceptedShares = acceptedShares;
string notificationReason = String.Format("Share(s) accepted for {0} (share {1})",
coinName, minerProcess.AcceptedShares);
notificationsControl.AddNotification(notificationReason, notificationReason, () =>
{
}, "");
}
}
示例4: logProcessClose
private void logProcessClose(MinerProcess minerProcess)
{
DateTime startDate = minerProcess.StartDate;
DateTime endDate = DateTime.Now;
string coinName = minerProcess.MinerConfiguration.CoinName;
double priceAtStart = 0;
string coinSymbol = String.Empty;
//coin may not be in CoinChoose.com
if (minerProcess.CoinInformation != null)
{
coinSymbol = minerProcess.CoinInformation.Symbol;
priceAtStart = minerProcess.CoinInformation.Price;
}
double priceAtEnd = priceAtStart;
//can't use Single here - coin info may be gone now and we crash
CoinInformation coinInfo = coinInformation.SingleOrDefault(c => c.Symbol.Equals(coinSymbol, StringComparison.OrdinalIgnoreCase));
if (coinInfo != null)
priceAtEnd = coinInfo.Price;
List<int> deviceIndexes = minerProcess.MinerConfiguration.DeviceIndexes;
logProcessClose(startDate, endDate, coinName, coinSymbol, priceAtStart, priceAtEnd, deviceIndexes);
}
示例5: GetDeviceInfoFromProcess
private List<DeviceInformationResponse> GetDeviceInfoFromProcess(MinerProcess minerProcess)
{
Xgminer.Api.ApiContext apiContext = minerProcess.ApiContext;
//setup logging
apiContext.LogEvent -= LogApiEvent;
apiContext.LogEvent += LogApiEvent;
List<DeviceInformationResponse> deviceInformationList = null;
try
{
try
{
deviceInformationList = apiContext.GetDeviceInformation().Where(d => d.Enabled).ToList();
}
catch (IOException ex)
{
//don't fail and crash out due to any issues communicating via the API
deviceInformationList = null;
}
}
catch (SocketException ex)
{
//won't be able to connect for the first 5s or so
deviceInformationList = null;
}
return deviceInformationList;
}
示例6: GetProcessDevices
private List<DeviceDetailsResponse> GetProcessDevices(MinerProcess minerProcess, List<DeviceInformationResponse> deviceInformationList)
{
List<DeviceDetailsResponse> processDevices = null;
if (processDeviceDetails.ContainsKey(minerProcess))
{
processDevices = processDeviceDetails[minerProcess];
foreach (DeviceInformationResponse deviceInformation in deviceInformationList)
{
DeviceDetailsResponse deviceDetails = processDevices.SingleOrDefault(d => d.Name.Equals(deviceInformation.Name, StringComparison.OrdinalIgnoreCase)
&& (d.ID == deviceInformation.ID));
if (deviceDetails == null)
{
//devs API returned a device not in the previous DEVDETAILS response
//need to clear our previous response and get a new one
processDevices = null;
break;
}
}
}
if (processDevices == null)
{
processDevices = GetDeviceDetailsFromProcess(minerProcess);
processDeviceDetails[minerProcess] = processDevices;
}
return processDevices;
}
示例7: setupProcessStartInfo
private void setupProcessStartInfo(MinerProcess minerProcess)
{
string coinName = minerProcess.MinerConfiguration.CoinName;
string coinSymbol = engineConfiguration.CoinConfigurations.Single(c => c.CryptoCoin.Name.Equals(coinName, StringComparison.OrdinalIgnoreCase)).CryptoCoin.Symbol;
CoinInformation processCoinInfo = null;
if (coinInformation != null) //null if no network connection
processCoinInfo = coinInformation.SingleOrDefault(c => c.Symbol.Equals(coinSymbol, StringComparison.OrdinalIgnoreCase));
//coin may not be in Coin API
if (processCoinInfo != null)
minerProcess.CoinInformation = processCoinInfo;
minerProcess.StartDate = DateTime.Now;
}
示例8: FlagSuspiciousProxy
private static void FlagSuspiciousProxy(MinerProcess minerProcess, List<DeviceInformation> deviceInformationList)
{
double currentProxyHashrate = deviceInformationList
.Where(device => device.Name.Equals("PXY", StringComparison.OrdinalIgnoreCase))
.Sum(device => device.CurrentHashrate);
double averageProxyHashrate = deviceInformationList
.Where(device => device.Name.Equals("PXY", StringComparison.OrdinalIgnoreCase))
.Sum(device => device.AverageHashrate);
//proxy is 0 hashrate and used to have a positive hashrate
if ((averageProxyHashrate > 0) && (currentProxyHashrate == 0))
{
minerProcess.HasZeroHashrateDevice = true;
}
}
示例9: RebaseGpuDeviceIndexes
private void RebaseGpuDeviceIndexes(MinerProcess minerProcess, List<int> deviceIndexes)
{
//we need to rebase GPUs here so that they match the rebasing done in CreateMinerConfiguration()
if (minerProcess.MinerConfiguration.Algorithm == CoinAlgorithm.Scrypt)
{
int firstGpuIndex = GetIndexOfFirstGpu();
for (int i = 0; i < deviceIndexes.Count; i++)
deviceIndexes[i] += firstGpuIndex;
}
}
示例10: StartMining
private void StartMining()
{
IEnumerable<string> coinSymbols = engineConfiguration.DeviceConfigurations
.Where(c => c.Enabled && !string.IsNullOrEmpty(c.CoinSymbol))
.Select(c => c.CoinSymbol)
.Distinct();
int port = engineConfiguration.XgminerConfiguration.StartingApiPort;
foreach (string coinSymbol in coinSymbols)
{
MinerConfiguration minerConfiguration = CreateMinerConfiguration(port, coinSymbol);
Process process = LaunchMinerProcess(minerConfiguration, "Starting mining");
if (!process.HasExited)
{
MinerProcess minerProcess = new MinerProcess();
minerProcess.Process = process;
minerProcess.ApiPort = port;
minerProcess.MinerConfiguration = minerConfiguration;
setupProcessStartInfo(minerProcess);
minerProcesses.Add(minerProcess);
}
port++;
}
mining = true;
}
示例11: FlagSuspiciousMiner
private void FlagSuspiciousMiner(MinerProcess minerProcess, DeviceInformation deviceInformation)
{
if (deviceInformation.Status.ToLower().Contains("sick"))
minerProcess.HasSickDevice = true;
if (deviceInformation.Status.ToLower().Contains("dead"))
minerProcess.HasDeadDevice = true;
if (deviceInformation.CurrentHashrate == 0)
minerProcess.HasZeroHashrateDevice = true;
//only check GPUs for subpar hashrate
//ASICs spike too much for this to be reliable there
//don't check average hashrate if using dynamic intensity
if (deviceInformation.Kind.Equals("GPU", StringComparison.OrdinalIgnoreCase) &&
!engineConfiguration.XgminerConfiguration.DesktopMode)
{
//avoid div by 0
if (deviceInformation.AverageHashrate > 0)
{
double performanceRatio = deviceInformation.CurrentHashrate / deviceInformation.AverageHashrate;
if (performanceRatio <= 0.50)
minerProcess.HasPoorPerformingDevice = true;
}
}
double effectiveHashrate = WorkUtilityToHashrate(deviceInformation.WorkUtility);
//avoid div by 0
if (deviceInformation.AverageHashrate > 0)
{
double performanceRatio = effectiveHashrate / deviceInformation.AverageHashrate;
if (performanceRatio <= 0.25)
minerProcess.StoppedAcceptingShares = true;
}
}
示例12: logProcessClose
private void logProcessClose(MinerProcess minerProcess)
{
DateTime startDate = minerProcess.StartDate;
DateTime endDate = DateTime.Now;
string coinName = minerProcess.MinerConfiguration.CoinName;
double priceAtStart = 0;
string coinSymbol = String.Empty;
//coin may not be in CoinChoose.com
if (minerProcess.CoinInformation != null)
{
coinSymbol = minerProcess.CoinInformation.Symbol;
priceAtStart = minerProcess.CoinInformation.Price;
}
double priceAtEnd = priceAtStart;
//can't use Single here - coin info may be gone now and we crash
CoinInformation coinInfo = null;
if (coinInformation != null) //null if no internet connection
coinInfo = coinInformation.SingleOrDefault(c => c.Symbol.Equals(coinSymbol, StringComparison.OrdinalIgnoreCase));
if (coinInfo != null)
priceAtEnd = coinInfo.Price;
//get a copy using ToList() so we can change the list in the event handler without
//affecting relaunching processes
List<int> deviceIndexes = minerProcess.MinerConfiguration.DeviceIndexes.ToList();
logProcessClose(startDate, endDate, coinName, coinSymbol, priceAtStart, priceAtEnd, deviceIndexes, minerProcess.MinerConfiguration);
}
示例13: StoreMinerProcess
private MinerProcess StoreMinerProcess(Process process, MinerDescriptor miner, string coinSymbol, Xgminer.Data.Configuration.Miner minerConfiguration, int apiPort)
{
MinerProcess minerProcess = new MinerProcess()
{
Process = process,
Miner = miner,
ApiPort = apiPort,
MinerConfiguration = minerConfiguration,
CoinSymbol = coinSymbol
};
setupProcessStartInfo(minerProcess);
minerProcesses.Add(minerProcess);
return minerProcess;
}
示例14: GetDeviceIndexForDeviceDetails
private int GetDeviceIndexForDeviceDetails(DeviceDetails deviceDetails, MinerProcess minerProcess)
{
int result = devices
.FindIndex((device) => {
return device.Driver.Equals(deviceDetails.Driver, StringComparison.OrdinalIgnoreCase)
&&
(
//serial == serial && path == path (serial may not be unique)
(!String.IsNullOrEmpty(device.Serial) && device.Serial.Equals(deviceDetails.Serial, StringComparison.OrdinalIgnoreCase)
&& !String.IsNullOrEmpty(device.Path) && device.Path.Equals(deviceDetails.DevicePath, StringComparison.OrdinalIgnoreCase))
//serial == serial && path == String.Empty - WinUSB/LibUSB has no path, but has a serial #
|| (!String.IsNullOrEmpty(device.Serial) && device.Serial.Equals(deviceDetails.Serial, StringComparison.OrdinalIgnoreCase)
&& String.IsNullOrEmpty(device.Path) && String.IsNullOrEmpty(deviceDetails.DevicePath))
//path == path
|| (!String.IsNullOrEmpty(device.Path) && device.Path.Equals(deviceDetails.DevicePath, StringComparison.OrdinalIgnoreCase))
//proxy == proxy && ID = RelativeIndex
|| (device.Driver.Equals("proxy", StringComparison.OrdinalIgnoreCase) && (minerProcess.MinerConfiguration.DeviceDescriptors.Contains(device)))
//opencl = opencl && ID = RelativeIndex
|| (device.Driver.Equals("opencl", StringComparison.OrdinalIgnoreCase) && (device.RelativeIndex == deviceDetails.ID))
//cpu = cpu && ID = RelativeIndex
|| (device.Driver.Equals("cpu", StringComparison.OrdinalIgnoreCase) && (device.RelativeIndex == deviceDetails.ID))
);
});
return result;
}
示例15: logProcessClose
private void logProcessClose(MinerProcess minerProcess)
{
if (this.LogProcessClose == null)
return;
DateTime startDate = minerProcess.StartDate;
DateTime endDate = DateTime.Now;
string coinName = minerProcess.MinerConfiguration.CoinName;
double priceAtStart = 0;
string coinSymbol = String.Empty;
//coin may not be in Coin API
if (minerProcess.CoinInformation != null)
{
coinSymbol = minerProcess.CoinInformation.Symbol;
priceAtStart = minerProcess.CoinInformation.Price;
}
double priceAtEnd = priceAtStart;
//can't use Single here - coin info may be gone now and we crash
CoinInformation coinInfo = null;
if (coinInformation != null) //null if no internet connection
coinInfo = coinInformation.SingleOrDefault(c => c.Symbol.Equals(coinSymbol, StringComparison.OrdinalIgnoreCase));
if (coinInfo != null)
priceAtEnd = coinInfo.Price;
//get a copy using ToList() so we can change the list in the event handler without
//affecting relaunching processes
List<DeviceDescriptor> deviceDescriptors = minerProcess.MinerConfiguration.DeviceDescriptors.ToList();
LogProcessCloseArgs args = new LogProcessCloseArgs();
args.StartDate = startDate;
args.EndDate = endDate;
args.CoinName = coinName;
args.CoinSymbol = coinSymbol;
args.StartPrice = priceAtStart;
args.EndPrice = priceAtEnd;
args.DeviceDescriptors = deviceDescriptors;
args.MinerConfiguration = minerProcess.MinerConfiguration;
args.AcceptedShares = minerProcess.AcceptedShares;
this.LogProcessClose(this, args);
}