public async Task Run() { var web3 = new Web3.Web3(TestConfiguration.BlockchainUrls.Infura.Rinkeby); var transactionHandler = new SimpleTransactionHandler(); var handlers = new HandlerContainer { TransactionHandler = transactionHandler }; //only tx sent to this address var transactionFilter = TransactionFilter.To("0xc0e15e11306334258d61fee52a22d15e6c9c59e0"); var filter = new FilterContainer(transactionFilter); var blockProcessor = BlockProcessorFactory.Create( web3, handlers, filter, processTransactionsInParallel: false); var processingStrategy = new ProcessingStrategy(blockProcessor); var blockchainProcessor = new BlockchainProcessor(processingStrategy); var result = await blockchainProcessor.ExecuteAsync(2830143, 2830153); Assert.True(result); Assert.Equal(12, transactionHandler.TransactionsHandled.Count); Assert.Empty(transactionHandler.ContractCreationTransactionsHandled); }
public async Task IndexingTransferFunctions() { using (var azureSearchService = new AzureSearchService(AzureSearchServiceName, _azureSearchApiKey)) { await azureSearchService.DeleteIndexAsync(AzureTransferIndexName); using (var azureFunctionMessageIndexer = await azureSearchService.GetOrCreateFunctionIndex <TransferFunction>(indexName: AzureTransferIndexName)) { var transferHandler = new FunctionIndexTransactionHandler <TransferFunction>(azureFunctionMessageIndexer); var web3 = new Web3.Web3("https://rinkeby.infura.io/v3/25e7b6dfc51040b3bfc0e47317d38f60"); var blockchainProxy = new BlockchainProxyService(web3); var handlers = new HandlerContainer { TransactionHandler = transferHandler }; var blockProcessor = BlockProcessorFactory.Create(blockchainProxy, handlers); var processingStrategy = new ProcessingStrategy(blockProcessor); var blockchainProcessor = new BlockchainProcessor(processingStrategy); var blockRange = new BlockRange(3146684, 3146694); await blockchainProcessor.ProcessAsync(blockRange); await Task.Delay(TimeSpan.FromSeconds(5)); //ensure we have written the expected docs to the index Assert.Equal(3, await azureFunctionMessageIndexer.DocumentCountAsync()); } await azureSearchService.DeleteIndexAsync(AzureTransferIndexName); } }
public async Task Run() { var blockchainProxyService = new BlockchainProxyService("https://rinkeby.infura.io/v3/25e7b6dfc51040b3bfc0e47317d38f60"); var transactionHandler = new SimpleTransactionHandler(); var handlers = new HandlerContainer { TransactionHandler = transactionHandler }; //only tx sent to this address var transactionFilter = TransactionFilter.To("0xc0e15e11306334258d61fee52a22d15e6c9c59e0"); var filter = new FilterContainer(transactionFilter); var blockProcessor = BlockProcessorFactory.Create( blockchainProxyService, handlers, filter, processTransactionsInParallel: false); var processingStrategy = new ProcessingStrategy(blockProcessor); var blockchainProcessor = new BlockchainProcessor(processingStrategy); var result = await blockchainProcessor.ExecuteAsync(2830143, 2830153); Assert.True(result); Assert.Equal(12, transactionHandler.TransactionsHandled.Count); Assert.Empty(transactionHandler.ContractCreationTransactionsHandled); }
public GetFeedsFromVkProcess(IVkConnectionBuilder vkConnectionBuilder, IVkGroupRepository groupRepository, ILog log, IConfigurationProvider configProvider, IDateTimeHelper dateTimeHelper, IWebUtilities webUtilities) { this.log = log; this.configProvider = configProvider; this.dateTimeHelper = dateTimeHelper; this.webUtilities = webUtilities; this.vkConnectionBuilder = vkConnectionBuilder; this.groupRepository = groupRepository; IProcessingStrategy strategy = new ProcessingStrategy(configProvider, groupRepository, this.dateTimeHelper); this.feedProviders = new List <IFeedProvider> { new WallPostFeedProvider(this.log, this.dateTimeHelper, strategy), new WallPostCommentsFeedProvider(this.log, Factory.GetInstance <IPostRepository>(), this.dateTimeHelper, strategy), new PhotoFeedProvider(this.log, this.dateTimeHelper, strategy), new PhotoAlbumDetailsFeedProvider(Factory.GetInstance <IPhotoRepository>(), this.dateTimeHelper, this.log), new MembersFeedProvider(this.log, this.dateTimeHelper), new MembersCountFeedProvider(this.log, this.dateTimeHelper), new MemberLikesFeedProvider(this.log, this.dateTimeHelper, Factory.GetInstance <IListRepository>(), Factory.GetInstance <IVkResponseMapper>(), strategy), new MemberSharesFeedProvider(this.log, this.dateTimeHelper, Factory.GetInstance <IListRepository>(), Factory.GetInstance <IVkResponseMapper>(), strategy), new MemberSubscriptionFeedProvider(this.log, Factory.GetInstance <IListRepository>(), Factory.GetInstance <IVkResponseMapper>(), Factory.GetInstance <IVkDataLimits>(), this.dateTimeHelper), new VideoFeedProvider(this.log, this.dateTimeHelper, strategy), new VideoCommentFeedProvider(this.log, Factory.GetInstance <IVideoRepository>(), this.dateTimeHelper, strategy), new VideoLikesFeedProvider(this.log, Factory.GetInstance <IVideoRepository>(), Factory.GetInstance <IVkResponseMapper>(), this.dateTimeHelper, strategy), new AdminsFeedProvider(this.log, this.dateTimeHelper), new TopicFeedProvider(this.log, this.dateTimeHelper, strategy), new TopicCommentFeedProvider(this.log, Factory.GetInstance <ITopicRepository>(), this.dateTimeHelper, strategy) }.ToDictionary(x => x.SupportedFeedType); }
static void Main(string[] args) { // This particular sample should be run with the following CLI args // A random contract on the Rinkeby network was chosen as an example // --Blockchain rinkeby --FromBlock 3146650 System.Console.WriteLine("CLI args: " + string.Join(" ", args)); var appConfig = ConfigurationUtils.Build(args).AddConsoleLogging(); var targetBlockchain = BlockchainSourceConfigurationFactory.Get(appConfig); System.Console.WriteLine($"Target Node/Name (URL): {targetBlockchain.Name}, {targetBlockchain.BlockchainUrl}"); //only process transactions that created or called our contract var filters = new ContractSpecificFilterBuilder(ContractAddress).Filters; //for specific functions on our contract, output the name and input arg values var transactionRouter = new TransactionRouter(); transactionRouter.AddContractCreationHandler( new ContractCreationPrinter <GlitchGoonsItemConstructor>()); transactionRouter.AddTransactionHandler(new FunctionPrinter <BuyApprenticeFunction>()); transactionRouter.AddTransactionHandler(new FunctionPrinter <OpenChestFunction>()); //for specific events, output the values var transactionLogRouter = new TransactionLogRouter(); transactionLogRouter.AddHandler(new EventPrinter <TransferEvent>()); var handlers = new HandlerContainer() { TransactionHandler = transactionRouter, TransactionLogHandler = transactionLogRouter, }; var blockchainProxy = new BlockchainProxyService(targetBlockchain.BlockchainUrl); var blockProcessor = BlockProcessorFactory.Create( blockchainProxy, handlers, filters, processTransactionsInParallel: false); var strategy = new ProcessingStrategy(blockProcessor) { MinimumBlockConfirmations = 6 //wait for 6 block confirmations before processing block }; var blockchainProcessor = new BlockchainProcessor(strategy); blockchainProcessor.ExecuteAsync (targetBlockchain.FromBlock, targetBlockchain.ToBlock) .GetAwaiter().GetResult(); System.Console.WriteLine($"Contracts Created: {transactionRouter.ContractsCreated}"); System.Console.WriteLine($"Transactions Handled: {transactionRouter.TransactionsHandled}"); System.Console.ReadLine(); }
public NowProcessingForm(ProcessingStrategy strategy, Type[] files) { InitializeComponent(); _strategy = strategy; _files = files; _progressBar.Value = 0; _progressBar.Maximum = 100; }
/// <summary> /// Initializes a new instance of the <see cref="VisitorOrderProcessor" /> class. /// </summary> /// <param name="innerProcessor">The inner processor.</param> /// <param name="processingStrategy">The processing strategy.</param> /// <param name="repository">The repository.</param> /// <param name="orderSecurity">The order security.</param> public VisitorOrderProcessor(OrderProcessor innerProcessor, ProcessingStrategy processingStrategy, Repository<Order> repository, VisitorOrderSecurity orderSecurity) { Assert.IsNotNull(innerProcessor, "Unable to cancel the order. Inner Order Processor cannot be null."); Assert.IsNotNull(processingStrategy, "Unable to cancel the order. Order Processing Strategy cannot be null."); Assert.IsNotNull(repository, "Unable to cancel the order. Order Repository cannot be null."); Assert.IsNotNull(orderSecurity, Texts.UnableToSaveTheOrdersOrderSecurityCannotBeNull); this.innerProcessor = innerProcessor; this.processingStrategy = processingStrategy; this.repository = repository; this.orderSecurity = orderSecurity; }
/// <summary> /// Initializes a new instance of the <see cref="VisitorOrderProcessor" /> class. /// </summary> /// <param name="innerProcessor">The inner processor.</param> /// <param name="processingStrategy">The processing strategy.</param> /// <param name="repository">The repository.</param> /// <param name="orderSecurity">The order security.</param> public VisitorOrderProcessor(OrderProcessor innerProcessor, ProcessingStrategy processingStrategy, Repository <Order> repository, VisitorOrderSecurity orderSecurity) { Assert.IsNotNull(innerProcessor, "Unable to cancel the order. Inner Order Processor cannot be null."); Assert.IsNotNull(processingStrategy, "Unable to cancel the order. Order Processing Strategy cannot be null."); Assert.IsNotNull(repository, "Unable to cancel the order. Order Repository cannot be null."); Assert.IsNotNull(orderSecurity, Texts.UnableToSaveTheOrdersOrderSecurityCannotBeNull); this.innerProcessor = innerProcessor; this.processingStrategy = processingStrategy; this.repository = repository; this.orderSecurity = orderSecurity; }
public void ShouldThrowWhenProvidedUnsupportedProcessingStrategy() { // Given const ProcessingStrategy processingStrategy = (ProcessingStrategy)3; var imageProvider = new Mock <IImageProvider>().Object; var imageProcessingChain = new Mock <IImageProcessingChain>().Object; var receiveProcessedImageCommand = new Mock <IReceiveProcessedImageCommand>().Object; var factory = new ProcessingEngineFactory(); var template = new ProcessingEngineTemplate { ProcessingStrategy = processingStrategy, ImageProvider = imageProvider, ImageProcessingChain = imageProcessingChain, ReceiveProcessedImageCommand = receiveProcessedImageCommand }; // When // Then Assert.Throws <ArgumentOutOfRangeException>(() => factory.CreateInstance(template)); }
public void ShouldCreateInstanceOfProcessingEngine(ProcessingStrategy processingStrategy) { // Given var imageProvider = new Mock <IImageProvider>().Object; var imageProcessingChain = new Mock <IImageProcessingChain>().Object; var receiveProcessedImageCommand = new Mock <IReceiveProcessedImageCommand>().Object; var factory = new ProcessingEngineFactory(); var template = new ProcessingEngineTemplate { ProcessingStrategy = processingStrategy, ImageProvider = imageProvider, ImageProcessingChain = imageProcessingChain, ReceiveProcessedImageCommand = receiveProcessedImageCommand }; // When var engine = factory.CreateInstance(template); // Then Assert.IsNotNull(engine); }
public async Task IndexingTransferFunctions() { using (var azureSearchService = new AzureSearchService(AzureSearchServiceName, _azureSearchApiKey)) { await azureSearchService.DeleteIndexAsync(AzureTransferIndexName); try { using (var azureFunctionMessageIndexer = await azureSearchService.CreateFunctionIndexer <TransferFunction>( indexName: AzureTransferIndexName)) { var transferHandler = new FunctionIndexTransactionHandler <TransferFunction>(azureFunctionMessageIndexer); var web3 = new Web3.Web3(TestConfiguration.BlockchainUrls.Infura.Rinkeby); var blockchainProxy = new BlockchainProxyService(web3); var handlers = new HandlerContainer { TransactionHandler = transferHandler }; var blockProcessor = BlockProcessorFactory.Create(blockchainProxy, handlers); var processingStrategy = new ProcessingStrategy(blockProcessor); var blockchainProcessor = new BlockchainProcessor(processingStrategy); var blockRange = new BlockRange(3146684, 3146694); await blockchainProcessor.ProcessAsync(blockRange); await Task.Delay(TimeSpan.FromSeconds(5)); //ensure we have written the expected docs to the index Assert.Equal(3, await azureFunctionMessageIndexer.DocumentCountAsync()); } } finally { await azureSearchService.DeleteIndexAsync(AzureTransferIndexName); } } }
public async Task Run() { var web3 = new Web3.Web3(TestConfiguration.BlockchainUrls.Infura.Rinkeby); var transactionHandler = new SimpleTransactionHandler(); var handlers = new HandlerContainer { TransactionHandler = transactionHandler }; var blockProcessor = BlockProcessorFactory.Create( web3, handlers, processTransactionsInParallel: false); var processingStrategy = new ProcessingStrategy(blockProcessor); var blockchainProcessor = new BlockchainProcessor(processingStrategy); var result = await blockchainProcessor.ExecuteAsync(2830144, 2830145); Assert.True(result); Assert.Equal(20, transactionHandler.TransactionsHandled?.Count); Assert.Equal(5, transactionHandler.ContractCreationsHandled?.Count); }
public async Task Run() { var contractAddresses = new[] { "0xd2e474c616cc60fb95d8b5f86c1043fa4552611b" }; const ulong FromBlock = 4347; const ulong ToBlock = 4347; var web3geth = new Web3Geth(); var blockchainProxyService = new BlockchainProxyService(web3geth); var transactionHandler = new SimpleTransactionHandler(); var vmStackHandler = new VmStackHandler(); var contractHandler = new ContractHandler(); foreach (var contractAddress in contractAddresses) { contractHandler.ContractAddresses.Add(contractAddress); } var handlers = new HandlerContainer { ContractHandler = contractHandler, TransactionHandler = transactionHandler, TransactionVmStackHandler = vmStackHandler }; var blockProcessor = BlockProcessorFactory.Create( blockchainProxyService, handlers, processTransactionsInParallel: false, postVm: true); var processingStrategy = new ProcessingStrategy(blockProcessor) { }; var blockchainProcessor = new BlockchainProcessor(processingStrategy); var result = await blockchainProcessor.ExecuteAsync(FromBlock, ToBlock); Assert.True(result); }
public async Task Run() { var blockchainProxy = new BlockchainProxyService("https://rinkeby.infura.io/v3/25e7b6dfc51040b3bfc0e47317d38f60"); var transactionHandler = new SimpleTransactionHandler(); var handlers = new HandlerContainer { TransactionHandler = transactionHandler }; var blockProcessor = BlockProcessorFactory.Create( blockchainProxy, handlers, processTransactionsInParallel: false); var processingStrategy = new ProcessingStrategy(blockProcessor); var blockchainProcessor = new BlockchainProcessor(processingStrategy); var result = await blockchainProcessor.ExecuteAsync(2830144, 2830145); Assert.True(result); Assert.Equal(20, transactionHandler.TransactionsHandled?.Count); Assert.Equal(5, transactionHandler.ContractCreationsHandled?.Count); }