Exemple #1
0
        public async Task UsingTheIndividualComponents()
        {
            TransferMetadata.CurrentChainUrl = BlockchainUrl;

            var web3 =
                new Web3.Web3(BlockchainUrl);

            using (var azureSearchService = new AzureSearchService(AzureSearchServiceName, _azureSearchApiKey))
            {
                await azureSearchService.DeleteIndexAsync(AzureTransferIndexName);

                try
                {
                    using (var transferIndexer =
                               await azureSearchService.CreateEventIndexer <TransferEvent_ERC20>(AzureTransferIndexName))
                    {
                        using (var transferProcessor =
                                   new EventIndexProcessor <TransferEvent_ERC20>(transferIndexer))
                        {
                            var logProcessor = new BlockRangeLogsProcessor(
                                web3.Eth.Filters.GetLogs,
                                new ILogProcessor[] { transferProcessor });

                            var progressRepository =
                                new JsonBlockProgressRepository(CreateJsonFileToHoldProgress());

                            var progressService = new StaticBlockRangeProgressService(
                                3146684, 3146694, progressRepository);

                            var batchProcessorService = new LogsProcessor(
                                logProcessor, progressService, maxNumberOfBlocksPerBatch: 2);

                            BlockRange?lastBlockRangeProcessed;
                            do
                            {
                                lastBlockRangeProcessed = await batchProcessorService.ProcessOnceAsync();
                            } while (lastBlockRangeProcessed != null);

                            Assert.Equal(19, transferIndexer.Indexed);
                        }
                    }
                }
                finally
                {
                    await azureSearchService.DeleteIndexAsync(AzureTransferIndexName);
                }
            }
        }