Exemple #1
0
        private static void FilterAndOutput <T>(TableArguments args, List <T> queryResult) where T : IEOSTable
        {
            List <dynamic> filteredFieldObject = null;

            if (args.fieldList != null)
            {
                foreach (var field in args.fieldList)
                {
                    if (typeof(T).GetProperty(field) == null)
                    {
                        Console.WriteLine(string.Format("Table rows do not contain field \"{0}\"", field));
                        return;
                    }
                }

                filteredFieldObject = EOSUtility.FilterFields(args.fieldList, queryResult);
            }

            if (args.outputFormat == OutputFormats.json)
            {
                string json = string.Empty;
                if (filteredFieldObject == null)
                {
                    json = JsonConvert.SerializeObject(queryResult, Formatting.Indented);
                }
                else
                {
                    json = JsonConvert.SerializeObject(filteredFieldObject, Formatting.Indented);
                }

                Console.WriteLine(json);
            }
            else
            {
                if (filteredFieldObject == null)
                {
                    Console.Write(queryResult.ToCsv());
                }
                else
                {
                    Console.Write(filteredFieldObject.ToCsv());
                }
            }
        }
Exemple #2
0
        public static void GetVoters()
        {
            StringBuilder tsvoutput = new StringBuilder();

            var voters = tableAPI.GetVoterRows();

            EOSUtility.UpdateProxyVotersWithProducerInfo(ref voters);

            int  voted = 0;
            int  producerMatchCount = 0;
            long producerstake      = 0;
            long totalstake         = 0;

            foreach (var voter in voters)
            {
                if (voter.producers.Count > 0)
                {
                    voted++;
                    totalstake = totalstake + voter.staked;
                    foreach (var producervote in voter.producers)
                    {
                        producerMatchCount++;
                        producerstake = producerstake + voter.staked;
                        tsvoutput.AppendLine(string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}", producervote, voter.voterDescription, voter.staked / 10000, voter.last_vote_weight_for_this_account_only, voter.last_vote_weight, voter.proxied_vote_weight, String.Join(",", voter.producers.Select(x => x.ToString()).ToArray())));
                    }
                }
            }


            Console.WriteLine(voters.Count + " Records returned");
            if (voters.Count > 0)
            {
                Console.WriteLine(voters[0].owner + " = 1st record");
                Console.WriteLine(voted + " have voted");
                Console.WriteLine(totalstake + " tokens staked ");
            }

            File.WriteAllText("report.txt", tsvoutput.ToString());
        }