Пример #1
0
        public static void Main(string[] args)
        {
            var blockService          = new BlockService();
            var serverInfoService     = new ServerInfoService();
            var assetService          = new AssetExchangeService();
            var currentHeight         = serverInfoService.GetBlockchainStatus().Result.NumberOfBlocks;
            var blockHeight           = 335690;
            Block <Transaction> block = null;

            if (args.Length > 0 && args[0].Equals("-height", StringComparison.InvariantCultureIgnoreCase))
            {
                int.TryParse(args[1], out blockHeight);
            }

            Console.WriteLine("Start scanning blockchain at height: {0}", blockHeight);
            for (; blockHeight < currentHeight; blockHeight++)
            {
                block = blockService.GetBlockIncludeTransactions(BlockLocator.ByHeight(blockHeight)).Result;
                foreach (var transaction in block.Transactions.Where(transaction => transaction.SubType == TransactionSubType.ColoredCoinsDividendPayment))
                {
                    var attachment = (ColoredCoinsDividendPaymentAttachment)transaction.Attachment;
                    var asset      = assetService.GetAsset(attachment.AssetId).Result;
                    Console.WriteLine("{0} {1} {2} {3}", transaction.Timestamp.ToString("d"), transaction.TransactionId, asset.Name, attachment.AmountPerQnt.Nxt);
                }
            }
            if (block != null)
            {
                Console.WriteLine("Last checked block height: {0} ({1})", blockHeight, block.Timestamp.ToString(CultureInfo.InvariantCulture));
            }
            Console.ReadLine();
        }
Пример #2
0
        static void Main(string[] args)
        {
            var options = Parse(args);

            _service = new AssetExchangeService();
            var transactionService = new TransactionService();

            _asset = _service.GetAsset(options.AssetId, true).Result;
            _assetDecimalFactor = (decimal)Math.Pow(10, -_asset.Decimals);

            var transfers             = GetAssetTransfers(_asset);
            var trades                = GetAssetTrades(_asset);
            var assetIssueTransaction = transactionService.GetTransaction(GetTransactionLocator.ByTransactionId(_asset.AssetId)).Result;

            if (assetIssueTransaction.Timestamp.CompareTo(options.StartDate) > 0)
            {
                options.StartDate = assetIssueTransaction.Timestamp;
            }

            Console.WriteLine($"Asset Name     : {_asset.Name}");
            Console.WriteLine($"Asset ID       : {_asset.AssetId}");
            Console.WriteLine($"Asset Trades   : {_asset.NumberOfTrades}");
            Console.WriteLine($"Asset Transfers: {_asset.NumberOfTransfers}");
            Console.WriteLine($"Issue Date     : {assetIssueTransaction.Timestamp:g}");
            Console.WriteLine($"Start Date     : {options.StartDate:d}");
            Console.WriteLine("------------------------------------------------");

            if (options.Range == Range.Daily)
            {
                WriteDailyData(options.StartDate, trades, transfers);
            }
            if (options.Range == Range.Weekly)
            {
                WriteWeeklyData(options.StartDate, trades, transfers);
            }
            if (options.Range == Range.Monthly)
            {
                WriteMonthlyData(options.StartDate, trades, transfers);
            }
            if (options.Range == Range.Yearly)
            {
                WriteYearlyData(options.StartDate, trades, transfers);
            }

            Console.WriteLine("Press enter to quit");
            Console.ReadLine();
        }