public async Task <List <float> > CalculateLuck(int countblock) { HashRate hashRate = new HashRate(); float hrn = float.Parse(await hashRate.Rate()) / 1000; Pool pool = new Pool(); string viabtc = "ViaBTC"; string slushpool = "SlushPool"; string viabtchash = pool.Parse(viabtc); string slushpoolhash = pool.Parse(slushpool); viabtchash = viabtchash.Substring(0, viabtchash.Length - 5).Replace(",", "").Replace(".", ","); slushpoolhash = slushpoolhash.Substring(0, slushpoolhash.Length - 5).Replace(",", "").Replace(".", ","); //Console.WriteLine(viabtchash); float viabtcpie = (((float.Parse(viabtchash) * 100 / hrn)) * countblock) / 100; float slushpoolpie = (((float.Parse(slushpoolhash) * 100 / hrn)) * countblock) / 100; EFBlockRepository eFBlock = new EFBlockRepository(); IEnumerable <Block> countb = eFBlock.Blocks.OrderByDescending(x => x.height).Take(countblock); int countviabtc = countb.Where(x => x.poolname == viabtc).Count(); int countslushpool = countb.Where(x => x.poolname == slushpool).Count(); float luckviabtc = 100 * countviabtc / viabtcpie; float luckslushpool = 100 * countslushpool / slushpoolpie; Console.WriteLine(luckviabtc); Console.WriteLine(luckslushpool); List <float> luck = new List <float>() { luckviabtc, luckslushpool }; return(luck); }
public override int GetHashCode() { unchecked { int hashCode = TimeStamp.GetHashCode(); hashCode = (hashCode * 397) ^ HashRate.GetHashCode(); hashCode = (hashCode * 397) ^ (int)HashCount; hashCode = (hashCode * 397) ^ (int)Found; hashCode = (hashCode * 397) ^ Difficulty.GetHashCode(); hashCode = (hashCode * 397) ^ (int)Height; return(hashCode); } }
internal async Task DownloadHashRate() { InfluxConfig configSecrets = configManager.GetSecretToken(); HashRateApi hashRateApi = new HashRateApi(new HttpClient(), configManager.GetQuandlSetting().ApiKey); DataSourceIdentification dataSourceIdentification = new DataSourceIdentification(organizationId, bucketHashRate); InfluxDbData.Repository <HashRate> repo = new InfluxDbData.Repository <HashRate>(new InfluxContext(configSecrets.Url, configSecrets.Token)); HashRate lastRecord = (await repo.GetLastWrittenRecordsTime(dataSourceIdentification).ConfigureAwait(false)).SingleOrDefault(); IEnumerable <HashRate> data = (await hashRateApi.GetData(lastRecord?.Time ?? DateTime.MinValue)).Select(g => new HashRate { Value = g.Value, Time = g.Time.ToUniversalTime() }); foreach (HashRate model in data) { await repo.Write(model, dataSourceIdentification).ConfigureAwait(false); } }
protected override HashRate Run(CancellationToken cancel) { if (cancel.IsCancellationRequested) { cancel.ThrowIfCancellationRequested(); } var hashRate = new HashRate(); var lines = ProcessHelper.ReadLines( Miner.Path, $"--algo={Algorithm} --benchmark --no-color --quiet --devices={MiningHardware.Index} --time-limit 15", cancel ); foreach (var line in lines) { Logger.Debug(line); var match = Regex.Match(line, @"\G\[.*\]\s*Benchmark:\s*(\d+.\d+)\s*(.*)"); if (match.Success) { var hashRateString = match.Groups[1].Value; var metric = match.Groups[2].Value; try { var hashRateValue = double.Parse(hashRateString, CultureInfo.InvariantCulture); hashRate = new HashRate(hashRateValue, metric); } catch (Exception e) { Logger.Exception($"Could not read hashrate of {Algorithm} -> {hashRateString}", e); } } } return(hashRate); }
protected override HashRate Run(CancellationToken cancel) { var hashRate = new HashRate(); string additionalParameter; switch (MiningHardware.Type) { case HardwareType.OpenCl: additionalParameter = $"-G --opencl-platform {MiningHardware.PlatformIndex} --opencl-device {MiningHardware.Index}"; break; case HardwareType.Cuda: additionalParameter = $"-U --cuda-devices {MiningHardware.Index}"; break; default: additionalParameter = ""; break; } var lines = ProcessHelper.ReadLines(Miner.Path, $"--benchmark 5159080 {additionalParameter}", cancel); foreach (var line in lines) { Logger.Debug(line); var match = Regex.Match(line, @".*inner mean:\s(\S+)\sH/s"); if (match.Success) { var hashRateValue = double.Parse(match.Groups[1].Value); hashRate = new HashRate(hashRateValue, Metric.Unit); } } return(hashRate); }
private bool Equals(HashEntry other) { return(TimeStamp == other.TimeStamp && HashRate.Equals(other.HashRate) && HashCount == other.HashCount && Found == other.Found && Difficulty.Equals(other.Difficulty) && Height == other.Height); }
public async void CalculateProbability(string namepool)//Task<List<double>> CalculateProbability(string namepool,int countblock, int forecastblock) { int countblock = 1000; int forecastblock = 100; HashRate hashRate = new HashRate(); EFMinearRepository eFMinear = new EFMinearRepository(); //network hrt float hrn = float.Parse(await hashRate.Rate()) / 1000; Pool pool = new Pool(); //pool hrt string hashs = pool.Parse(namepool); //string hashs = pool.Parse("ViaBTC"); hashs = hashs.Substring(0, hashs.Length - 5).Replace(",", "").Replace(".", ","); double hash = double.Parse(hashs); //T double T = forecastblock * 10 / 60; //double T = 100 * 10 / 60; //BTC.com double btc = (T / 24) * 1.6 * 1000 * double.Parse(eFMinear.Minears.OrderBy(x => x.date).Select(x => x.fpps_mining_earnings).LastOrDefault(), CultureInfo.InvariantCulture); int countfb = (int)Math.Ceiling(btc / 1.6 * hash / 12.8); //Console.WriteLine("Необходимое количество найденных блоков для прибыли : {0} ", countfb); EFBlockRepository eFBlock = new EFBlockRepository(); IEnumerable <Block> countb = eFBlock.Blocks.OrderByDescending(x => x.height).Take(countblock); int count = countb.Where(x => x.poolname == namepool).Count(); //IEnumerable<Block> countb = eFBlock.Blocks.OrderByDescending(x => x.height).Take(1000); //int count = countb.Where(x => x.poolname == "ViaBTC").Count(); //P double P = Calc(hrn, hash, countblock, forecastblock, countfb, count); //double P = Calc(hrn, hash, 1000, 100, countfb, count); Console.WriteLine("{3} : Вероятность {1} для {2} и более блоков за {4} блоков : {0}%", P, namepool, countfb, DateTime.Now, forecastblock); //Console.WriteLine("Вероятность {1} : {0}%", P, namepool); //Revenue //double revenue1 = findblock * 1.6 / viabtchash * 12.8; //double revenue2 = findblock * 1.6 / slushpoolhash * 12.8; double revenue = (countfb * 1.6 / hash * 12.8) - btc; //Console.WriteLine("Доход {1} : {0} BTC", revenue, "ViaBTC"); Console.WriteLine("{3} : Доход {1} при {2} блоков : {0} BTC", revenue, namepool, countfb, DateTime.Now); //List<double> ret = new List<double> { P, revenue }; //return ret; //laplas double matwait = (hash / hrn) * 144; int maxheight = eFBlock.Blocks.OrderByDescending(x => x.height).Select(x => x.height).FirstOrDefault(); IEnumerable <Block> countbl = eFBlock.Blocks.OrderByDescending(x => x.height).Take(countblock); List <int> cntbl = new List <int>(); cntbl.Add(countbl.Where(x => x.height <= maxheight && x.height >= maxheight - 143 && x.poolname == namepool).Count()); cntbl.Add(countbl.Where(x => x.height < maxheight - 143 && x.height >= maxheight - 287 && x.poolname == namepool).Count()); cntbl.Add(countbl.Where(x => x.height < maxheight - 287 && x.height >= maxheight - 431 && x.poolname == namepool).Count()); cntbl.Add(countbl.Where(x => x.height < maxheight - 431 && x.height >= maxheight - 575 && x.poolname == namepool).Count()); cntbl.Add(countbl.Where(x => x.height < maxheight - 575 && x.height >= maxheight - 719 && x.poolname == namepool).Count()); Console.WriteLine("{3} : Вероятность {1} для {2} и более блоков : {0}%", Function.Function.FuncLaplas(cntbl, matwait, countfb) * 100, namepool, countfb, DateTime.Now); }
public CryptoCoinNetworkInfoBuilder AddHashRate(HashRate hashRate) { this.hashRate = hashRate; return(this); }
public void AAtest() { bool fine = false; string processName = "EthDcrMiner64"; string configFilePath = @"C:\ProgramData\CryptoCurrency\Ethereum\Claymore's Dual Ethereum+Decred_Siacoin_Lbry_Pascal AMD+NVIDIA GPU Miner v10.2\config.txt"; bool hasAPI = true; bool hasConfigurationSettings = true;; bool hasERROut = true; bool hasLogFiles = true; bool hasSTDOut = true; string logFileFnPattern = "\\d{10}_log.txt"; string logFileFolder = @"C:\ProgramData\CryptoCurrency\Ethereum\Claymore's Dual Ethereum+Decred_Siacoin_Lbry_Pascal AMD+NVIDIA GPU Miner v10.2";; string processPath = @"C:\ProgramData\CryptoCurrency\Ethereum\Claymore's Dual Ethereum+Decred_Siacoin_Lbry_Pascal AMD+NVIDIA GPU Miner v10.2\EthDcrMiner64.exe"; string processStartPath = @"C:\ProgramData\CryptoCurrency\Ethereum\Claymore's Dual Ethereum+Decred_Siacoin_Lbry_Pascal AMD+NVIDIA GPU Miner v10.2"; string version = "10.2"; Coin[] coinsMined = new Coin[2] { Coin.ETH, Coin.ZEC }; ConcurrentObservableDictionary <string, string> configurationSettings = new ConcurrentObservableDictionary <string, string>() { { "mport", "21200" }, { "epool", "eth-us-east1.nanopool.org:9999" }, { "epsw", "x" }, { "ewal", "0xcdac8dea6d3ced686bacc9622fb7f92d29ed8874.ncat-m01/[email protected]" }, { "esm", "STRATUMTYPE" }, { "mode", "0" }, { "dcoin", "sc" }, { "dpool", "stratum+tcp://sia-us-east1.nanopool.org:7777" }, { "dwal", "72cb72ceb7b2b6b7a06c3393bdbd2311e180bb14cd629960d5a017d2dc816043be77abf79efe.ncat-m01/[email protected]" }, { "dpsw", "x" }, { "dcri", "4" }, { "allpools", "0" }, { "ftime", "0" }, { "tt", "85" }, { "tstop", "90" }, //{"di","0" }, { "asm", "1" }, { "gser", "2" }, { "fanmin", "50" }, { "fanmax", "100" }, //{"benchmark", "170" }, { "cclock", "0" }, { "mclock", "0" }, }; VideoCardSignil localcardvcdc = VideoCardsKnown.TuningParameters.Keys.Where(x => (x.VideoCardMaker == VideoCardMaker.ASUS && x.GPUMaker == GPUMaker.NVIDEA)) .Single(); ConcurrentObservableDictionary <Coin, HashRate> hashRatePerCoin = new ConcurrentObservableDictionary <Coin, HashRate>(); MinerGPU minerGPU = new MinerGPU(localcardvcdc, "10DE 17C8 - 3842", "100.00001.02320.00", false, 1140, 1753, 11.13, 0.8, hashRatePerCoin); List <TuneMinerGPUsResult> tuneMinerGPUsResultList = new List <TuneMinerGPUsResult>(); MinerGPU[] minerGPUsToTune = new MinerGPU[1] { minerGPU }; // create the collection of MinerSWs to tune MinerSW[] minerSWsToTune = new MinerSW[1]; ClaymoreETHDualMinerSW claymoreETHDualMinerSW = new ClaymoreETHDualMinerSW(processName, processPath, processStartPath, version, hasConfigurationSettings, configurationSettings, configFilePath, hasLogFiles, logFileFolder, logFileFnPattern, hasAPI, hasSTDOut, hasERROut, coinsMined); minerSWsToTune[0] = claymoreETHDualMinerSW; foreach (var msw in minerSWsToTune) { // Move to the directory where this software expects to start Directory.SetCurrentDirectory(msw.ProcessStartPath); foreach (var mg in minerGPUsToTune) { // stop any running instances of this SW Process.GetProcessesByName(msw.ProcessName).ToList().ForEach(x => x.Kill()); // Select the tuning strategy for this MinerSW and this VideoCard var vcdc = mg.VideoCardSignil; var vctp = VideoCardsKnown.TuningParameters[vcdc]; // Calculate the step for each parameter int memoryClockStep = (vctp.MemoryClockMax - vctp.MemoryClockMin) / (fine ? 1 : 5); int coreClockStep = (vctp.CoreClockMax - vctp.CoreClockMin) / (fine ? 1 : 5); //double voltageStep = (vctp.VoltageMax - vctp.VoltageMin) / (fine ? 0.01 : 0.05); // memoryClock Min, max, step // CoreClock Min, max, step // memoryVoltage min, max, step int memoryClockTune; int coreClockTune; //double voltageTune = vctp.VoltageMin; ConcurrentObservableDictionary <Coin, HashRate> hashRatePerCoinTune; Power powerConsumptionTune; // ToDo: initialize the structures that monitor for miner SW stopping, or Rig rebooting //while (voltageTune <= vctp.VoltageMax) //{ coreClockTune = vctp.CoreClockMin; while (coreClockTune <= vctp.CoreClockMax) { msw.ConfigurationSettings["-cclock"] = coreClockTune.ToString(); memoryClockTune = vctp.MemoryClockMin; while (memoryClockTune <= vctp.MemoryClockMax) { msw.ConfigurationSettings["-mclock"] = memoryClockTune.ToString(); // Stop the miner software Process.GetProcessesByName(msw.ProcessName).ToList().ForEach(x => x.Kill()); // write the MinerSW Configuration to the miner's configuration file //Func<KeyValuePair, string> cfgpair = (x) => $"-{x.Key} {x.Value}"; string s = string.Join(Environment.NewLine, msw.ConfigurationSettings.Select(x => $"-{x.Key} {x.Value}")); System.IO.File.WriteAllText(msw.ConfigFilePath, s); // update the structures that monitor for miner SW stopping, or Rig rebooting // Start the miner process var cmd = Command.Run(processPath, new[] { "" }, options: o => o.DisposeOnExit(false)); //var outputLines = cmd.StandardOutput.GetLines().ToList(); //var errorText = cmd.StandardError.ReadToEnd(); // Wait a Delay for the card to settle Task.Delay(new TimeSpan(0, 0, 3)); // Get the current HashRate and power consumption //var minerStatus = await StatusFetchAsync(); // Dictionary<Coin, HashRate> hashRatesTune = new Dictionary<Coin, HashRate> { { Coin.ETH, new HashRate(1000.0, new TimeSpan(0, 0, 1)) } }; //PowerConsumption powerConsumptionTune = new PowerConsumption(); // Or Detect a minerSW stoppage or detect a rig reboot // Stop the miner process //cmd.Process.Close(); //todo: figure out DisposeOnExit(false) Process.GetProcessesByName(msw.ProcessName).ToList().ForEach(x => x.Kill()); powerConsumptionTune = new Power(1, UnitsNet.Units.PowerUnit.Watt); hashRatePerCoinTune = new ConcurrentObservableDictionary <Coin, HashRate>(); foreach (var k in msw.CoinsMined) { hashRatePerCoinTune[k] = new HashRate(1, new TimeSpan(0, 0, 1)); } // Record the results for this combination of msw,mvc,mClock,cClock,and mVoltage tuneMinerGPUsResultList.Add(new TuneMinerGPUsResult(coreClockTune, memoryClockTune, vctp.VoltageDefault, hashRatePerCoinTune, powerConsumptionTune)); if (memoryClockTune != vctp.MemoryClockMax) { memoryClockTune += memoryClockStep; memoryClockTune = memoryClockTune > vctp.MemoryClockMax ? vctp.MemoryClockMax : memoryClockTune; } else { memoryClockTune += 1; } } if (coreClockTune != vctp.CoreClockMax) { coreClockTune += coreClockStep; coreClockTune = coreClockTune > vctp.CoreClockMax ? vctp.CoreClockMax : coreClockTune; } else { coreClockTune += 1; } } //voltageTune += voltageStep; //voltageTune = voltageTune > vctp.VoltageMax ? vctp.VoltageMax : voltageTune; //} } // Best hashrate for this MinerSW, by order of coins mined //ConcurrentObservableDictionary<Coin, HashRate> bestHashRates //var bestMinerGPUResult = tuneMinerGPUsResultList.Max(x => x.HashRates[msw.CoinsMined[0]]); } //return tuneMinerGPUsResultList; Assert.Equal(1, 1); }
async Task PullWorkLoop() { while (!this.appConfiguration.Cts.IsCancellationRequested) { try { if (this.appConfiguration.Stake) { var getUnspentOutputsResponse = await this.rpcClient.GetUnspentOutputs(); var dumpWalletResponse = await this.rpcClient.DumpWallet(Path.Combine(this.appConfiguration.DataDirRoot.ToString(), "dumptemp.txt")); if (getUnspentOutputsResponse.Status == 200 && dumpWalletResponse.Status == 200) { PushToCoinsCache(getUnspentOutputsResponse.Result.result, dumpWalletResponse.Result.result, false); } } this.logger.LogInformation("Requesting block template..."); var getBlockTemplateResponse = await this.rpcClient.GetBlockTemplate(); if (getBlockTemplateResponse.Status != 200) { if (!this.appConfiguration.Cts.IsCancellationRequested) { this.logger.LogError("Block template was null, waiting 10 seconds before next request..."); await Task.Delay(10000); } continue; } if (getBlockTemplateResponse.Result.result.longpollid == prevLongPollId) { // if we would continue here, we'd just cancel the miner for nothing... this.logger.LogWarning("Block template is not new, ignoring and waiting 10 seconds before next request."); await Task.Delay(10000); continue; } else { prevLongPollId = getBlockTemplateResponse.Result.result.longpollid; } RPCBlockTemplate blockTemplate = getBlockTemplateResponse.Result.result; uint posBits = blockTemplate.ParseBits(true); uint powBits = blockTemplate.ParseBits(false); Target posTarget = new Target(posBits); Target powTarget = new Target(powBits); this.logger.LogInformation($"New block template: {blockTemplate.previousblockhash}-{blockTemplate.TemplateNumber} Block: {blockTemplate.height} Reward: {Money.Satoshis(blockTemplate.coinbasevalue)} X1{Environment.NewLine}" + $"Proof-of-Stake: Target: {blockTemplate.posbits} Difficulty: {posTarget.Difficulty.ToString("0").PadLeft(7)} Equivalent to PoW hash rate: { HashRate.EstimateGHashPerSecondFromBits(posBits).ToString("0.0").PadLeft(7)} GHash/s{Environment.NewLine}" + $"Proof-of-Work: Target: {blockTemplate.bits} Difficulty: {powTarget.Difficulty.ToString("0").PadLeft(7)} Estimated network hash rate: { HashRate.EstimateGHashPerSecondFromBits(powBits).ToString("0.0").PadLeft(7)} GHash/s"); this.blockTemplateCache.SetBlockTemplateLocked(blockTemplate); if (this.appConfiguration.Mine) { this.minerCoordinator.NotifyBlockTemplateReceived(blockTemplate.height % 2 != 0); } } catch (Exception e) { this.stakingService.BlockTemplate = null; if (!this.appConfiguration.Cts.IsCancellationRequested) { Console.WriteLine($"Error in PullWorkLoop: {e.Message}"); } } await Task.Delay(1000); } HasShutDown = true; }