public LogsSubscription( IJsonRpcDuplexClient jsonRpcDuplexClient, IReceiptMonitor receiptCanonicalityMonitor, IFilterStore?store, IBlockTree?blockTree, ILogManager?logManager, Filter?filter = null) : base(jsonRpcDuplexClient) { _blockTree = blockTree ?? throw new ArgumentNullException(nameof(blockTree)); _receiptCanonicalityMonitor = receiptCanonicalityMonitor ?? throw new ArgumentNullException(nameof(receiptCanonicalityMonitor)); _logger = logManager?.GetClassLogger() ?? throw new ArgumentNullException(nameof(logManager)); IFilterStore filterStore = store ?? throw new ArgumentNullException(nameof(store)); if (filter != null) { _filter = filterStore.CreateLogFilter( filter.FromBlock, filter.ToBlock, filter.Address, filter.Topics); if (_logger.IsTrace) { _logger.Trace($"Logs Subscription {Id}: Created LogFilter with the same arguments like \"filter\""); } } else { _filter = filterStore.CreateLogFilter( BlockParameter.Latest, BlockParameter.Latest); if (_logger.IsTrace) { _logger.Trace($"Logs Subscription {Id}: Argument \"filter\" was null and created LogFilter with arguments: FromBlock: BlockParameter.Latest, ToBlock: BlockParameter.Latest"); } } _receiptCanonicalityMonitor.ReceiptsInserted += OnReceiptsInserted; if (_logger.IsTrace) { _logger.Trace($"Logs subscription {Id} will track ReceiptsInserted."); } }
public SubscriptionFactory(ILogManager?logManager, IBlockTree?blockTree, ITxPool?txPool, IReceiptMonitor receiptCanonicalityMonitor, IFilterStore?filterStore, IEthSyncingInfo ethSyncingInfo, ISpecProvider specProvider, JsonSerializer jsonSerializer) { _jsonSerializer = jsonSerializer; logManager = logManager ?? throw new ArgumentNullException(nameof(logManager)); blockTree = blockTree ?? throw new ArgumentNullException(nameof(blockTree)); txPool = txPool ?? throw new ArgumentNullException(nameof(txPool)); receiptCanonicalityMonitor = receiptCanonicalityMonitor ?? throw new ArgumentNullException(nameof(receiptCanonicalityMonitor)); filterStore = filterStore ?? throw new ArgumentNullException(nameof(filterStore)); ethSyncingInfo = ethSyncingInfo ?? throw new ArgumentNullException(nameof(ethSyncingInfo)); specProvider = specProvider ?? throw new ArgumentNullException(nameof(specProvider)); _subscriptionConstructors = new ConcurrentDictionary <string, CustomSubscriptionType> { //Register the standard subscription types in the dictionary. [SubscriptionType.NewHeads] = CreateSubscriptionType <TransactionsOption?>((jsonRpcDuplexClient, args) => new NewHeadSubscription(jsonRpcDuplexClient, blockTree, logManager, specProvider, args)), [SubscriptionType.Logs] = CreateSubscriptionType <Filter?>((jsonRpcDuplexClient, filter) => new LogsSubscription(jsonRpcDuplexClient, receiptCanonicalityMonitor, filterStore, blockTree, logManager, filter)), [SubscriptionType.NewPendingTransactions] = CreateSubscriptionType <TransactionsOption?>((jsonRpcDuplexClient, args) => new NewPendingTransactionsSubscription(jsonRpcDuplexClient, txPool, logManager, args)), [SubscriptionType.DroppedPendingTransactions] = CreateSubscriptionType(jsonRpcDuplexClient => new DroppedPendingTransactionsSubscription(jsonRpcDuplexClient, txPool, logManager)), [SubscriptionType.Syncing] = CreateSubscriptionType(jsonRpcDuplexClient => new SyncingSubscription(jsonRpcDuplexClient, blockTree, ethSyncingInfo, logManager)) }; }