public void AddAmount(IDbConnection con, IDbTransaction tx, string poolId, CoinType coin, string address, decimal amount, string usage) { logger.LogInvoke(); var now = DateTime.UtcNow; // record balance change var query = "INSERT INTO balance_changes(poolid, coin, address, amount, usage, created) " + "VALUES(@poolid, @coin, @address, @amount, @usage, @created)"; var balanceChange = new Entities.BalanceChange { PoolId = poolId, Coin = coin.ToString(), Created = now, Address = address, Amount = amount, Usage = usage, }; con.Execute(query, balanceChange, tx); // update balance query = "SELECT * FROM balances WHERE poolid = @poolId AND coin = @coin AND address = @address"; var balance = con.Query <Entities.Balance>(query, new { poolId, coin = coin.ToString(), address }, tx) .FirstOrDefault(); if (balance == null) { balance = new Entities.Balance { PoolId = poolId, Coin = coin.ToString(), Created = now, Address = address, Amount = amount, Updated = now }; query = "INSERT INTO balances(poolid, coin, address, amount, created, updated) " + "VALUES(@poolid, @coin, @address, @amount, @created, @updated)"; con.Execute(query, balance, tx); } else { query = "UPDATE balances SET amount = amount + @amount, updated = now() at time zone 'utc' " + "WHERE poolid = @poolId AND coin = @coin AND address = @address"; con.Execute(query, new { poolId, address, coin = coin.ToString().ToUpper(), amount }, tx); } }
/// <summary> /// Lookup CryptoCompare data using miner's preferred fiat currency /// </summary> private HistoDayResponse GetCryptoCompare(CoinType coinType) { try { HistoDayResponse histoDayResponse = new HistoDayResponse(); // Exit if no fiat currency is selected if (Application.Current.Properties["Currency"] == null) { return(new HistoDayResponse()); } string fiatCurrencyISOSymbol = Application.Current.Properties["Currency"].ToString(); // Load CryptoCompare data CryptoCompareAPI cryptoCompareAPI = new CryptoCompareAPI(); histoDayResponse = cryptoCompareAPI.GetCryptoCompareResponse(coinType.ToString(), fiatCurrencyISOSymbol); return(histoDayResponse); } catch (Exception e) { ShowError(string.Format("Error loading coin market cap data: {0}", e.Message)); return(new HistoDayResponse()); } }
private CoinInfo GetCoinInfoFromCryptoCompare(CoinType coinType) { var url = "https://min-api.cryptocompare.com/data/price?fsym=" + coinType.ToString() + "&tsyms=BTC,USD"; var json = new WebClient().DownloadString(url); var response = JsonConvert.DeserializeObject <CryoptoCompareResponse>(json); return(new CoinInfo { CoinType = coinType, Name = coinType.ToString(), CoinMarketCapId = 0, PriceUSD = response.USD, PriceBTC = response.BTC, Updated = DateTime.Now }); }
private void OnTriggerEnter(Collider other) { if (other.gameObject.name == "Negrinho") { gameObject.SetActive(false); Debug.Log("Negrinho coleta a moeda e o seu tipo é " + coinType.ToString()); SetCoins((int)coinType); //SFX da Moeda sfxColetarMoeda.PlayAudio(); } }
public void AddAmount(IDbConnection con, IDbTransaction tx, string poolId, CoinType coin, string address, decimal amount) { var query = "SELECT * FROM balances WHERE poolid = @poolId AND coin = @coin AND address = @address"; var balance = con.Query <Entities.Balance>(query, new { poolId, coin = coin.ToString(), address }, tx) .FirstOrDefault(); var now = DateTime.UtcNow; if (balance == null) { balance = new Entities.Balance { PoolId = poolId, Coin = coin.ToString(), Created = now, Address = address, Amount = amount, Updated = now }; query = "INSERT INTO balances(poolid, coin, address, amount, created, updated) " + "VALUES(@poolid, @coin, @address, @amount, @created, @updated)"; con.Execute(query, balance, tx); } else { balance.Updated = now; balance.Amount += amount; query = "UPDATE balances SET amount = @amount, updated = @updated " + "WHERE poolid = @poolId AND coin = @coin AND address = @address"; con.Execute(query, balance, tx); } }
public CoinInfo GetCoinInfo(IDbConnection con, CoinType coinType) { logger.LogInvoke(); var query = "SELECT * FROM coin_info WHERE cointype = @coin "; var results = con.Query <Entities.CoinInfo>(query, new { coin = coinType.ToString() }) .Select(mapper.Map <CoinInfo>) .ToArray(); if (results == null || results.Length == 0) { return(null); } return(results[0]); }
private void SetActualPlayer() { switch (actualPlayer) { case CoinType.NoOne: case CoinType.X: actualPlayer = CoinType.O; break; case CoinType.O: actualPlayer = CoinType.X; break; } Console.WriteLine($"E' il turno del giocatore {actualPlayer.ToString()}"); }
public void Run() { var gameEnded = false; var winner = CoinType.NoOne; while (!gameEnded) { // stampo la situazione attuale Console.Clear(); Console.WriteLine(this.ToString()); // accetto la prossima mossa SetActualPlayer(); var colNumber = AcceptNextMove(out int freePosition); this.grid[freePosition, colNumber] = actualPlayer; // verifico se con l'ultima mossa è stato creato un allineamento di 4 gettoni if (CheckFour(freePosition, colNumber)) { winner = actualPlayer; gameEnded = true; } // verifico se ho ancora spazio di gioco nella griglia if (OutOfSpace()) { gameEnded = true; } } // all'uscita dal ciclo, stampa la situazione finale Console.Clear(); Console.WriteLine(this.ToString()); if (winner == CoinType.NoOne) { Console.WriteLine($"Partita finita in pareggio."); } else { Console.WriteLine($"Quattro in fila! Il giocatore {actualPlayer.ToString()} vince!"); } Console.WriteLine(); }
public Coin(CoinType name) : this() { this.name = name.ToString(); this.fullName = ((CoinFullName)(int)name).ToString(); }
private async Task <MinerMonitorStat> GetRPCResponse() { MinerMonitorStat minerMonitorStat = new MinerMonitorStat(); try { var dictHW = PruvotApi.GetHwInfo(HostName, ApiPort); var dictHist = PruvotApi.GetHistory(HostName, ApiPort); minerMonitorStat.AccountGuid = (Guid)Application.Current.Properties["AccountID"]; minerMonitorStat.WorkerName = Application.Current.Properties["WorkerName"].ToString(); minerMonitorStat.CoinType = CoinType; minerMonitorStat.MinerBaseType = MinerBaseType; var gpuList = (from element in dictHist orderby element["GPU"] ascending select element["GPU"]).Distinct(); List <GPUMonitorStat> gpuMonitorStatList = new List <GPUMonitorStat>(); foreach (var gpuNumber in gpuList) { var gpuHash = (from element in dictHist orderby element["GPU"] ascending, element["TS"] descending where element["GPU"] == gpuNumber select element).FirstOrDefault(); var gpuHw = (from hw in dictHW where hw["GPU"] == gpuNumber select hw).FirstOrDefault(); // Create new GPU monitor stats object and map values GPUMonitorStat gpuMonitorStat = new GPUMonitorStat(); gpuMonitorStat.AccountGuid = (Guid)Application.Current.Properties["AccountID"]; gpuMonitorStat.WorkerName = Application.Current.Properties["WorkerName"].ToString(); gpuMonitorStat.CoinType = CoinType.ToString(); gpuMonitorStat.GPUID = Convert.ToInt32(gpuNumber); gpuMonitorStat.HashRate = (Convert.ToDecimal(gpuHash["KHS"])); gpuMonitorStat.FanSpeed = Convert.ToInt16(gpuHw["FAN"]); gpuMonitorStat.Temp = (short)Convert.ToDecimal(gpuHw["TEMP"]); gpuMonitorStat.Power = (short)(Convert.ToDecimal(gpuHw["POWER"]) / 1000); gpuMonitorStat.HardwareType = Hardware; // Sum up power and hashrate minerMonitorStat.Power += (short)gpuMonitorStat.Power; minerMonitorStat.HashRate += gpuMonitorStat.HashRate; // Add GPU stats to list gpuMonitorStatList.Add(gpuMonitorStat); } // Set list of GPU monitor stats minerMonitorStat.GPUMonitorStatList = gpuMonitorStatList; return(await Task.Run(() => { return minerMonitorStat; })); } catch (Exception ex) { NLogProcessing.LogError(ex, "Error calling GetRPCResponse from miner."); // Return null object; return(null); } }
/// <summary> /// GateIO可用 btc_usdt /// </summary> /// <param name="coin"></param> /// <param name="currency"></param> /// <returns></returns> public static string GateConvertSymbol(CoinType coin, CurrencyType currency) { return((coin.ToString() + "_" + currency.ToString()).ToLower()); }
public void WriteXml(XmlWriter writer) { writer.WriteAttributeString("Type", _Type.ToString()); writer.WriteAttributeString("Ammount", Ammount.ToString()); }
public static IEnumerable <Coin> TakeCoins(Participant fromParticipant, CoinType CT, int units) { IEnumerable <Coin> result = new List <Coin>(); if (fromParticipant.coins.Count(coin => coin.CT == CT) >= units) { result = fromParticipant.coins.Where(coin => coin.CT == CT); } else { throw new Exception("\n" + fromParticipant.Name + " is running out of " + CT.ToString() + "(s)"); } return(result.Take(units)); }
public static string DisplayCoinsSummary(IEnumerable <Coin> coins, CoinType CT) { return("[" + CT.ToString() + "s] - " + coins.Count().ToString() + "\t"); }
/// <summary> /// Withdraws the specified coin type and amount from the shared bank. /// </summary> /// <param name="type">coin type</param> /// <param name="amount">coin amount</param> /// <returns>call success</returns> public bool SharedBankWithdraw(CoinType type, int amount) { Trace.WriteLine(String.Format("Character:SharedBankWithdraw({0}, {1})", type, amount.ToString(CultureInfo.InvariantCulture))); return this.ExecuteMethod("SharedBankWithdraw", type.ToString()[0].ToString(CultureInfo.InvariantCulture), amount.ToString(CultureInfo.InvariantCulture)); }
/// <summary> /// Deposits the amount of the coin type provided into the bank. Optional third parameter will /// move the coin from the regular bank to the shared bank if true. /// </summary> /// <param name="type">coin type</param> /// <param name="amount">coin amount</param> /// <param name="useBank">use bank as source</param> /// <returns></returns> public bool SharedBankDeposit(CoinType type, int amount, bool useBank = false) { Trace.WriteLine(String.Format("Character:BankDeposit({0}, {1}, {2})", type, amount.ToString(CultureInfo.InvariantCulture), useBank)); return !useBank ? this.ExecuteMethod("BankDeposit", type.ToString()[0].ToString(CultureInfo.InvariantCulture), amount.ToString(CultureInfo.InvariantCulture)) : this.ExecuteMethod("BankDeposit", type.ToString()[0].ToString(CultureInfo.InvariantCulture), amount.ToString(CultureInfo.InvariantCulture), "FromBank"); }
/// <summary> /// 火币可用 btcusdt, bchbtc, rcneth /// </summary> /// <param name="coin"></param> /// <param name="currency"></param> /// <returns></returns> public static string HBConvertSymbol(CoinType coin, CurrencyType currency) { return("&symbol=" + (coin.ToString() + currency.ToString()).ToLower()); }
private async Task <MinerMonitorStat> GetRPCResponse() { MinerMonitorStat minerMonitorStat = new MinerMonitorStat(); try { var clientSocket = new TcpClient(); if (clientSocket.ConnectAsync(HostName, ApiPort).Wait(5000)) { //string get_menu_request = "{\"id\":1, \"method\":\"getstat\"}\n"; //string get_menu_request = "{\"id\":0,\"jsonrpc\":\"2.0\",\"method\":\"miner_getstat1\"}\n"; string get_menu_request = "summary"; NetworkStream serverStream = clientSocket.GetStream(); byte[] outStream = System.Text.Encoding.ASCII.GetBytes(get_menu_request); serverStream.Write(outStream, 0, outStream.Length); serverStream.Flush(); byte[] inStream = new byte[clientSocket.ReceiveBufferSize]; await serverStream.ReadAsync(inStream, 0, (int)clientSocket.ReceiveBufferSize); string returndata = System.Text.Encoding.ASCII.GetString(inStream); string[] jsonData = returndata.Split(','); //ewbfTemplate = JsonConvert.DeserializeObject<EWBFTemplate>(jsonData); // Close socket clientSocket.Close(); clientSocket = null; } else { NLogProcessing.LogInfo($"Could not connect to EWBF miner socket on port {ApiPort}"); // Return null object; return(null); } //var dictHW = PruvotApi.GetHwInfo(HostName, ApiPort); //var dictHist = PruvotApi.GetHistory(HostName, ApiPort); minerMonitorStat.AccountGuid = (Guid)Application.Current.Properties["AccountID"]; minerMonitorStat.WorkerName = Application.Current.Properties["WorkerName"].ToString(); minerMonitorStat.CoinType = CoinType; minerMonitorStat.MinerBaseType = MinerBaseType; var gpuList = new List <int> [0, 1, 2]; //(from element in dictHist // orderby element["GPU"] ascending // select element["GPU"]).Distinct(); List <GPUMonitorStat> gpuMonitorStatList = new List <GPUMonitorStat>(); foreach (var gpuNumber in gpuList) { //var gpuHash = (from element in dictHist // orderby element["GPU"] ascending, element["TS"] descending // where element["GPU"] == gpuNumber // select element).FirstOrDefault(); //var gpuHw = (from hw in dictHW // where hw["GPU"] == gpuNumber // select hw).FirstOrDefault(); // Create new GPU monitor stats object and map values GPUMonitorStat gpuMonitorStat = new GPUMonitorStat(); gpuMonitorStat.AccountGuid = (Guid)Application.Current.Properties["AccountID"]; gpuMonitorStat.WorkerName = Application.Current.Properties["WorkerName"].ToString(); gpuMonitorStat.CoinType = CoinType.ToString(); gpuMonitorStat.GPUID = Convert.ToInt32(gpuNumber); //gpuMonitorStat.HashRate = (Convert.ToDecimal(gpuHash["KHS"])); //gpuMonitorStat.FanSpeed = Convert.ToInt16(gpuHw["FAN"]); //gpuMonitorStat.Temp = (short)Convert.ToDecimal(gpuHw["TEMP"]); //gpuMonitorStat.Power = (short)(Convert.ToDecimal(gpuHw["POWER"]) / 1000); gpuMonitorStat.HardwareType = Hardware; // Sum up power and hashrate minerMonitorStat.Power += (short)gpuMonitorStat.Power; minerMonitorStat.HashRate += gpuMonitorStat.HashRate; // Add GPU stats to list gpuMonitorStatList.Add(gpuMonitorStat); } // Set list of GPU monitor stats minerMonitorStat.GPUMonitorStatList = gpuMonitorStatList; return(await Task.Run(() => { return minerMonitorStat; })); } catch (Exception ex) { NLogProcessing.LogError(ex, "Error calling GetRPCResponse from miner."); // Return null object; return(null); } }
/// <summary> /// OKEx可用,GateIO可用 btc_usdt /// </summary> /// <param name="coin"></param> /// <param name="currency"></param> /// <returns></returns> public static string ZBConvertSymbol(CoinType coin, CurrencyType currency) { return("market=" + (coin.ToString() + "_" + currency.ToString()).ToLower()); }
/// <summary> /// Sets the name/path of the LyclMiner config file /// </summary> private void SetupLyclConfigName() { MinerConfigFileName = $"lyclMiner{CoinType.ToString()}.conf"; MinerConfigArguments = MinerConfigFileName; // no switches, just the config file name for now }