Exemplo n.º 1
0
        private static bool processPastBlocks(string[] args)
        {
            var bids_helper  = new LoanBidsHelper();
            var latest_block = bids_helper.getLatestBlock();

            PrePrint("latest block: " + ((latest_block.HasValue) ? latest_block.Value.ToString() : "none"));

            if (args.Length > 0)
            {
                foreach (var block_hash in args)
                {
                    PrePrint("recover block " + block_hash);
                    var block_details   = Ethereum.GetBlockDetails(block_hash);
                    var block_processor = new BlockProcessor();
                    block_processor.onTransactionsTo = processTransactionsTo;
                    block_processor.processBlockDetails(block_details, block_callback: false);
                }
                return(false);
            }
            else if (latest_block.HasValue)
            {
                var block_details = Ethereum.GetBlockDetails((ulong)latest_block.Value);
                while (block_details != null)
                {
                    PrePrint("recover block " + block_details.hash);
                    var block_processor = new BlockProcessor();
                    block_processor.onTransactionsTo = processTransactionsTo;
                    block_processor.processBlockDetails(block_details, block_callback: false);
                    latest_block++;
                    block_details = Ethereum.GetBlockDetails((ulong)latest_block.Value);
                }
                PrePrint("recovering finished on block " + (latest_block - 1));
            }

            return(true);
        }