public Task GetProducers()
 {
     return(DefaultApi.GetProducers(new GetProducersRequest()
     {
         json = false,
     }));
 }
示例#2
0
        public async Task <IEnumerable <wallet.Models.Producer> > GetProducersAsync(ProducersRequest request)
        {
            var currencyBalance = await m_EosApi.GetCurrencyBalance(new GetCurrencyBalanceRequest()
            {
                code = "eosio.token", account = "eosio.txfee", symbol = "VHKD"
            });

            decimal totalUnpaidTxfees = 0;

            if (currencyBalance.assets.Count > 0)
            {
                totalUnpaidTxfees = decimal.Parse(currencyBalance.assets[0].Split(' ')[0]);
            }
            var globalData = await m_EosApi.GetTableRows(new GetTableRowsRequest()
            {
                json = true, code = "eosio", scope = "eosio", table = "global"
            });

            var globalObject           = (JObject)globalData.rows[0];
            var totalUnpaidTxfeeBlocks = (int)globalObject["total_unpaid_txfee_blocks"];
            var producers = await m_EosApi.GetProducers(new GetProducersRequest()
            {
                json = true, limit = request.Limit ?? 20
            });

            return(producers.rows.Cast <JObject>().Select(p => new wallet.Models.Producer()
            {
                Owner = p["owner"].ToString(),
                Localtion = "0",
                IsActive = "Active",
                UnpaidTxfee = Math.Round(totalUnpaidTxfees * (int)p["unpaid_txfee_blocks"] / totalUnpaidTxfeeBlocks, 4).ToString() + " VHKD"
            }).ToList());
        }