private void AddLocalMinerStatistics(List<MultiMiner.MobileMiner.Data.MiningStatistics> statisticsList) { //call ToList() so we can get a copy - otherwise risk: //System.InvalidOperationException: Collection was modified; enumeration operation may not execute. List<MinerProcess> minerProcesses = miningEngine.MinerProcesses.ToList(); foreach (MinerProcess minerProcess in minerProcesses) { List<DeviceInformation> deviceInformationList = GetDeviceInfoFromProcess(minerProcess); if (deviceInformationList == null) //handled failure getting API info continue; //starting with bfgminer 3.7 we need the DEVDETAILS response to tie things from DEVS up with -d? details List<DeviceDetails> processDevices = GetProcessDeviceDetails(minerProcess, deviceInformationList); if (processDevices == null) //handled failure getting API info continue; foreach (DeviceInformation deviceInformation in deviceInformationList) { MobileMiner.Data.MiningStatistics miningStatistics = new MobileMiner.Data.MiningStatistics(); miningStatistics.MachineName = Environment.MachineName; PopulateMobileMinerStatistics(miningStatistics, deviceInformation, GetCoinNameForApiContext(minerProcess.ApiContext)); DeviceDetails deviceDetails = processDevices.SingleOrDefault(d => d.Name.Equals(deviceInformation.Name, StringComparison.OrdinalIgnoreCase) && (d.ID == deviceInformation.ID)); int deviceIndex = GetDeviceIndexForDeviceDetails(deviceDetails, minerProcess); Xgminer.Data.Device device = devices[deviceIndex]; Engine.Data.Configuration.Coin coinConfiguration = CoinConfigurationForDevice(device); miningStatistics.FullName = GetFriendlyDeviceName(device); miningStatistics.PoolName = GetPoolNameByIndex(coinConfiguration, deviceInformation.PoolIndex).DomainFromHost(); statisticsList.Add(miningStatistics); } } }
private void AddNetworkMinerStatistics(List<MultiMiner.MobileMiner.Data.MiningStatistics> statisticsList) { //is Network Device detection enabled? if (!applicationConfiguration.NetworkDeviceDetection) return; //call ToList() so we can get a copy - otherwise risk: //System.InvalidOperationException: Collection was modified; enumeration operation may not execute. List<NetworkDevices.NetworkDevice> networkDevices = networkDevicesConfiguration.Devices.ToList(); foreach (Data.Configuration.NetworkDevices.NetworkDevice networkDevice in networkDevices) { List<DeviceInformation> deviceInformationList = GetDeviceInfoFromAddress(networkDevice.IPAddress, networkDevice.Port); if (deviceInformationList == null) //handled failure getting API info continue; List<PoolInformation> poolInformationList = GetCachedPoolInfoFromAddress(networkDevice.IPAddress, networkDevice.Port); Xgminer.Api.Data.VersionInformation versionInformation = GetVersionInfoFromAddress(networkDevice.IPAddress, networkDevice.Port); //we cannot continue without versionInformation as the MinerName is required by MobileMiner or it returns HTTP 400 if (versionInformation == null) //handled failure getting API info continue; foreach (DeviceInformation deviceInformation in deviceInformationList) { string devicePath = String.Format("{0}:{1}", networkDevice.IPAddress, networkDevice.Port); //don't submit stats until we have a valid ViewModel for the Network Device DeviceViewModel deviceViewModel = localViewModel.Devices.SingleOrDefault(d => d.Path.Equals(devicePath)); if (deviceViewModel == null) continue; MobileMiner.Data.MiningStatistics miningStatistics = new MobileMiner.Data.MiningStatistics() { // submit the Friendly device / machine name MachineName = GetFriendlyDeviceName(devicePath, devicePath), // versionInformation may be null if the read timed out MinerName = versionInformation == null ? String.Empty : versionInformation.Name, CoinName = KnownCoins.BitcoinName, CoinSymbol = KnownCoins.BitcoinSymbol, Algorithm = AlgorithmNames.SHA256 }; miningStatistics.PopulateFrom(deviceInformation); //ensure poolIndex is valid for poolInformationList //user(s) reported index errors so we can't out on the RPC API here //https://github.com/nwoolls/MultiMiner/issues/64 if ((deviceInformation.PoolIndex >= 0) && // poolInformationList may be null if an RPC API call timed out (poolInformationList != null) && (deviceInformation.PoolIndex < poolInformationList.Count)) { string poolUrl = poolInformationList[deviceInformation.PoolIndex].Url; miningStatistics.PoolName = poolUrl.DomainFromHost(); Coin coinConfiguration = CoinConfigurationForPoolUrl(poolUrl); if (coinConfiguration != null) { miningStatistics.CoinName = coinConfiguration.CryptoCoin.Name; miningStatistics.CoinSymbol = coinConfiguration.CryptoCoin.Symbol; //MobileMiner is only SHA & Scrypt for now if ((coinConfiguration.CryptoCoin.Algorithm == CoinAlgorithm.SHA256) || (coinConfiguration.CryptoCoin.Algorithm == CoinAlgorithm.Keccak)) miningStatistics.Algorithm = AlgorithmNames.SHA256; else miningStatistics.Algorithm = AlgorithmNames.Scrypt; } } statisticsList.Add(miningStatistics); } } }
private void AddNetworkMinerStatistics(List<MultiMiner.MobileMiner.Data.MiningStatistics> statisticsList) { //is Network Device detection enabled? if (!applicationConfiguration.NetworkDeviceDetection) return; foreach (Data.Configuration.NetworkDevices.NetworkDevice networkDevice in networkDevicesConfiguration.Devices) { List<DeviceInformation> deviceInformationList = GetDeviceInfoFromAddress(networkDevice.IPAddress, networkDevice.Port); if (deviceInformationList == null) //handled failure getting API info continue; List<PoolInformation> poolInformationList = GetCachedPoolInfoFromAddress(networkDevice.IPAddress, networkDevice.Port); Xgminer.Api.Data.VersionInformation versionInformation = GetVersionInfoFromAddress(networkDevice.IPAddress, networkDevice.Port); foreach (DeviceInformation deviceInformation in deviceInformationList) { string devicePath = String.Format("{0}:{1}", networkDevice.IPAddress, networkDevice.Port); MobileMiner.Data.MiningStatistics miningStatistics = new MobileMiner.Data.MiningStatistics() { // submit the Friendly device / machine name MachineName = GetFriendlyDeviceName(devicePath, devicePath), // versionInformation may be null if the read timed out MinerName = versionInformation == null ? String.Empty : versionInformation.Name, CoinName = NetworkDeviceCoinName, CoinSymbol = NetworkDeviceCoinSymbol, Algorithm = AlgorithmNames.SHA256 }; miningStatistics.PopulateFrom(deviceInformation); //ensure poolIndex is valid for poolInformationList //user(s) reported index errors so we can't out on the RPC API here //https://github.com/nwoolls/MultiMiner/issues/64 if ((deviceInformation.PoolIndex >= 0) && // poolInformationList may be null if an RPC API call timed out (poolInformationList != null) && (deviceInformation.PoolIndex < poolInformationList.Count)) miningStatistics.PoolName = poolInformationList[deviceInformation.PoolIndex].Url.DomainFromHost(); statisticsList.Add(miningStatistics); } } }
private void AddLocalMinerStatistics(List<MultiMiner.MobileMiner.Data.MiningStatistics> statisticsList) { foreach (MinerProcess minerProcess in miningEngine.MinerProcesses) { List<DeviceInformation> deviceInformationList = GetDeviceInfoFromProcess(minerProcess); if (deviceInformationList == null) //handled failure getting API info continue; //starting with bfgminer 3.7 we need the DEVDETAILS response to tie things from DEVS up with -d? details List<DeviceDetails> processDevices = GetProcessDeviceDetails(minerProcess, deviceInformationList); foreach (DeviceInformation deviceInformation in deviceInformationList) { MobileMiner.Data.MiningStatistics miningStatistics = new MobileMiner.Data.MiningStatistics(); miningStatistics.MachineName = Environment.MachineName; PopulateMiningStatistics(miningStatistics, deviceInformation, GetCoinNameForApiContext(minerProcess.ApiContext)); DeviceDetails deviceDetails = processDevices.SingleOrDefault(d => d.Name.Equals(deviceInformation.Name, StringComparison.OrdinalIgnoreCase) && (d.ID == deviceInformation.ID)); int deviceIndex = GetDeviceIndexForDeviceDetails(deviceDetails); Xgminer.Data.Device device = devices[deviceIndex]; Engine.Data.Configuration.Coin coinConfiguration = CoinConfigurationForDevice(device); miningStatistics.FullName = device.Name; miningStatistics.PoolName = GetPoolNameByIndex(coinConfiguration, deviceInformation.PoolIndex).DomainFromHost(); statisticsList.Add(miningStatistics); } } }
private void SubmitMobileMinerStatistics() { //are remote monitoring enabled? if (!applicationConfiguration.MobileMinerMonitoring) return; //is MobileMiner configured? if (string.IsNullOrEmpty(applicationConfiguration.MobileMinerApplicationKey) || string.IsNullOrEmpty(applicationConfiguration.MobileMinerEmailAddress)) return; List<MultiMiner.MobileMiner.Data.MiningStatistics> statisticsList = new List<MobileMiner.Data.MiningStatistics>(); foreach (MinerProcess minerProcess in miningEngine.MinerProcesses) { List<DeviceInformation> deviceInformationList = GetDeviceInfoFromProcess(minerProcess); if (deviceInformationList == null) //handled failure getting API info continue; //starting with bfgminer 3.7 we need the DEVDETAILS response to tie things from DEVS up with -d? details List<DeviceDetails> processDevices = GetProcessDeviceDetails(minerProcess, deviceInformationList); foreach (DeviceInformation deviceInformation in deviceInformationList) { MobileMiner.Data.MiningStatistics miningStatistics = new MobileMiner.Data.MiningStatistics(); PopulateMiningStatistics(miningStatistics, deviceInformation, GetCoinNameForApiContext(minerProcess.ApiContext)); DeviceDetails deviceDetails = processDevices.SingleOrDefault(d => d.Name.Equals(deviceInformation.Name, StringComparison.OrdinalIgnoreCase) && (d.ID == deviceInformation.ID)); int deviceIndex = GetDeviceIndexForDeviceDetails(deviceDetails); Xgminer.Data.Device device = devices[deviceIndex]; Engine.Data.Configuration.Coin coinConfiguration = CoinConfigurationForDevice(device); miningStatistics.FullName = device.Name; miningStatistics.PoolName = GetPoolNameByIndex(coinConfiguration, deviceInformation.PoolIndex).DomainFromHost(); statisticsList.Add(miningStatistics); } } if (statisticsList.Count > 0) { if (submitMiningStatisticsDelegate == null) submitMiningStatisticsDelegate = SubmitMiningStatistics; submitMiningStatisticsDelegate.BeginInvoke(statisticsList, Environment.MachineName, submitMiningStatisticsDelegate.EndInvoke, null); } }
private void SubmitMobileMinerNetworkDeviceStatistics(NetworkDevices.NetworkDevice networkDevice) { //are remote monitoring enabled? if (!applicationConfiguration.MobileMinerMonitoring) return; //is MobileMiner configured? if (string.IsNullOrEmpty(applicationConfiguration.MobileMinerApplicationKey) || string.IsNullOrEmpty(applicationConfiguration.MobileMinerEmailAddress)) return; List<MultiMiner.MobileMiner.Data.MiningStatistics> statisticsList = new List<MobileMiner.Data.MiningStatistics>(); List<DeviceInformation> deviceInformationList = GetDeviceInfoFromAddress(networkDevice.IPAddress, networkDevice.Port); if (deviceInformationList == null) //handled failure getting API info return; List<PoolInformation> poolInformationList = GetCachedPoolInfoFromAddress(networkDevice.IPAddress, networkDevice.Port); Xgminer.Api.Data.VersionInformation versionInformation = new Xgminer.Api.ApiContext(networkDevice.Port, networkDevice.IPAddress).GetVersionInformation(); foreach (DeviceInformation deviceInformation in deviceInformationList) { MobileMiner.Data.MiningStatistics miningStatistics = new MobileMiner.Data.MiningStatistics() { MinerName = versionInformation.Name, CoinName = NetworkDeviceCoinName, CoinSymbol = NetworkDeviceCoinSymbol, Algorithm = "SHA-256" }; miningStatistics.PopulateFrom(deviceInformation); //ensure poolIndex is valid for poolInformationList //user(s) reported index errors so we can't out on the RPC API here //https://github.com/nwoolls/MultiMiner/issues/64 if ((deviceInformation.PoolIndex >= 0) && (deviceInformation.PoolIndex < poolInformationList.Count)) miningStatistics.PoolName = poolInformationList[deviceInformation.PoolIndex].Url.DomainFromHost(); statisticsList.Add(miningStatistics); } if (statisticsList.Count > 0) { if (submitMiningStatisticsDelegate == null) submitMiningStatisticsDelegate = SubmitMiningStatistics; submitMiningStatisticsDelegate.BeginInvoke(statisticsList, networkDevice.IPAddress, submitMiningStatisticsDelegate.EndInvoke, null); } }
private void AddNetworkMinerStatistics(List<MultiMiner.MobileMiner.Data.MiningStatistics> statisticsList) { //is Network Device detection enabled? if (!applicationConfiguration.NetworkDeviceDetection) return; foreach (Data.Configuration.NetworkDevices.NetworkDevice networkDevice in networkDevicesConfiguration.Devices) { List<DeviceInformation> deviceInformationList = GetDeviceInfoFromAddress(networkDevice.IPAddress, networkDevice.Port); if (deviceInformationList == null) //handled failure getting API info continue; List<PoolInformation> poolInformationList = GetCachedPoolInfoFromAddress(networkDevice.IPAddress, networkDevice.Port); Xgminer.Api.Data.VersionInformation versionInformation = new Xgminer.Api.ApiContext(networkDevice.Port, networkDevice.IPAddress).GetVersionInformation(); foreach (DeviceInformation deviceInformation in deviceInformationList) { MobileMiner.Data.MiningStatistics miningStatistics = new MobileMiner.Data.MiningStatistics() { MachineName = String.Format("{0}:{1}", networkDevice.IPAddress, networkDevice.Port), MinerName = versionInformation.Name, CoinName = NetworkDeviceCoinName, CoinSymbol = NetworkDeviceCoinSymbol, Algorithm = "SHA-256" }; miningStatistics.PopulateFrom(deviceInformation); //ensure poolIndex is valid for poolInformationList //user(s) reported index errors so we can't out on the RPC API here //https://github.com/nwoolls/MultiMiner/issues/64 if ((deviceInformation.PoolIndex >= 0) && (deviceInformation.PoolIndex < poolInformationList.Count)) miningStatistics.PoolName = poolInformationList[deviceInformation.PoolIndex].Url.DomainFromHost(); statisticsList.Add(miningStatistics); } } }