Ejemplo n.º 1
0
        protected override async Task HandleAsync(FeesAction action, IDispatcher dispatcher)
        {
            var stats    = client.GetFeeStats();         // .GetFeeStatsAsync();
            var sbResult = await client.GetLastServiceBlock();

            var sb     = sbResult.GetBlock() as ServiceBlock;
            var voters = client.GetVoters(new VoteQueryModel
            {
                posAccountIds = sb.Authorizers.Keys.ToList(),
                endTime       = sb.TimeStamp
            });

            dispatcher.Dispatch(new FeesResultAction(stats, sb, voters));
        }
        private async Task <(string, long)> GetMaxHeightAsync(Block block)
        {
            BlockAPIResult lastBlockResult = null;

            switch (block)
            {
            case ServiceBlock sb:
                lastBlockResult = await client.GetLastServiceBlock();

                break;

            case ConsolidationBlock cb:
                lastBlockResult = await client.GetLastConsolidationBlock();

                break;

            case TransactionBlock tb:
                var tbLastResult = await client.GetAccountHeight(tb.AccountID);

                if (tbLastResult.ResultCode == APIResultCodes.Success)
                {
                    return(tb.AccountID, tbLastResult.Height);
                }
                break;

            default:
                break;
            }

            if (lastBlockResult != null && lastBlockResult.ResultCode == APIResultCodes.Success)
            {
                var lb = lastBlockResult.GetBlock();
                return(lb.BlockType.ToString(), lb.Height);
            }
            else
            {
                return(null, 0);
            }
        }