Пример #1
0
        public int OnExecute(CommandLineApplication app, IConsole console)
        {
            var client  = new HiveOsAutomation.ApiClients.HiveOs.Client(Program.Configuration.HiveOsApiEndPoint, Program.Configuration.HiveOsApiPublicKey, Program.Configuration.HiveOsApiSecretKey);
            var wallets = client.GetWallets();

            foreach (var wallet in wallets)
            {
                console.WriteLine($"Id: {wallet.Id}, name: {wallet.Name}");
            }

            return(0);
        }
Пример #2
0
        public int OnExecute(CommandLineApplication app, IConsole console)
        {
            var hiveOsApiClient     = new HiveOsAutomation.ApiClients.HiveOs.Client(Program.Configuration.HiveOsApiEndPoint, Program.Configuration.HiveOsApiPublicKey, Program.Configuration.HiveOsApiSecretKey);
            var whattomineApiClient = new HiveOsAutomation.ApiClients.Whattomine.Client(Program.Configuration.WhattomineApiEndPoint, Program.Configuration.WhattomineApiExchanges);

            var rigsStatus = hiveOsApiClient.GetRigs();
            var wallets    = hiveOsApiClient.GetWallets();
            var overclocks = hiveOsApiClient.GetOverclocks();

            foreach (var rig in Program.Configuration.Rigs)
            {
                var whattomineParams = rig.Algorithms.Select(a => new AlgorithmParams
                {
                    HashRate        = a.Hashrate,
                    PowerConsumtion = a.PowerConsumption,
                    Algorithm       = a.Type
                });

                var profits =
                    whattomineApiClient.Get(whattomineParams)
                    .Where(a => !a.Lagging)
                    .OrderByDescending(a => a.Profitability)
                    .ThenByDescending(a => a.Profitability24)
                    .ThenByDescending(a => a.MarketCap);

                foreach (var profit in profits)
                {
                    var algo =
                        rig.Algorithms.Where(a =>
                                             a.Type == profit.Algorithm &&
                                             a.Tags.Any(b => b.Names.Contains(profit.Tag)))
                        .FirstOrDefault();

                    var tag = algo?.Tags.Single(a => a.Names.Contains(profit.Tag));

                    if (algo != null)
                    {
                        var wallet    = wallets.Single(a => a.Name == tag.Wallet);
                        var overclock = overclocks.SingleOrDefault(a => a.Name == algo.Overclock);

                        foreach (var status in rigsStatus.Where(a => rig.Names.Contains(a.Name)))
                        {
                            eMinerSoftware?miner    = null;
                            int?           walletId = null;

                            if (status.WalletId != wallet.Id)
                            {
                                walletId = wallet.Id;
                            }

                            if (status.Miner != tag.Miner)
                            {
                                miner = tag.Miner;
                            }

                            if (miner.HasValue || walletId.HasValue)
                            {
                                hiveOsApiClient.MultiRocket(
                                    new [] { status.Id },
                                    miner,
                                    null,
                                    walletId,
                                    overclock?.Id);
                            }
                        }

                        break;
                    }
                }
            }

            return(0);
        }