private IComparer <Transaction> CreateTxPoolTxComparer(TxPriorityContract?txPriorityContract, TxPriorityContract.LocalDataSource?localDataSource) { if (txPriorityContract != null || localDataSource != null) { ContractDataStore <Address> whitelistContractDataStore = new ContractDataStoreWithLocalData <Address>( new HashSetContractDataStoreCollection <Address>(), txPriorityContract?.SendersWhitelist, _api.BlockTree, _api.ReceiptFinder, _api.LogManager, localDataSource?.GetWhitelistLocalDataSource() ?? new EmptyLocalDataSource <IEnumerable <Address> >()); DictionaryContractDataStore <TxPriorityContract.Destination> prioritiesContractDataStore = new DictionaryContractDataStore <TxPriorityContract.Destination>( new TxPriorityContract.DestinationSortedListContractDataStoreCollection(), txPriorityContract?.Priorities, _api.BlockTree, _api.ReceiptFinder, _api.LogManager, localDataSource?.GetPrioritiesLocalDataSource()); _api.DisposeStack.Push(whitelistContractDataStore); _api.DisposeStack.Push(prioritiesContractDataStore); IComparer <Transaction> txByPermissionComparer = new CompareTxByPermissionOnHead(whitelistContractDataStore, prioritiesContractDataStore, _api.BlockTree); return(CompareTxByGasPrice.Instance .ThenBy(txByPermissionComparer) .ThenBy(CompareTxByTimestamp.Instance) .ThenBy(CompareTxByPoolIndex.Instance) .ThenBy(CompareTxByGasLimit.Instance)); } return(CreateTxPoolTxComparer()); }
protected override TxPoolTxSource CreateTxPoolTxSource() { TxPoolTxSource txPoolTxSource = base.CreateTxPoolTxSource(); TxPriorityContract = new TxPriorityContract(new AbiEncoder(), TestItem.AddressA, new ReadOnlyTxProcessingEnv(DbProvider, TrieStore.AsReadOnly(), BlockTree, SpecProvider, LimboLogs.Instance)); Priorities = new DictionaryContractDataStore <TxPriorityContract.Destination>( new TxPriorityContract.DestinationSortedListContractDataStoreCollection(), TxPriorityContract.Priorities, BlockTree, ReceiptStorage, LimboLogs.Instance, GetPrioritiesLocalDataStore()); MinGasPrices = new DictionaryContractDataStore <TxPriorityContract.Destination>( new TxPriorityContract.DestinationSortedListContractDataStoreCollection(), TxPriorityContract.MinGasPrices, BlockTree, ReceiptStorage, LimboLogs.Instance, GetMinGasPricesLocalDataStore()); SendersWhitelist = new ContractDataStoreWithLocalData <Address>(new HashSetContractDataStoreCollection <Address>(), TxPriorityContract.SendersWhitelist, BlockTree, ReceiptStorage, LimboLogs.Instance, GetWhitelistLocalDataStore()); return(txPoolTxSource); }
private TxPoolTxSource CreateTxPoolTxSource(ReadOnlyTxProcessingEnv processingEnv, IReadOnlyTxProcessorSource readOnlyTxProcessorSource) { // We need special one for TxPriority as its following Head separately with events and we want rules from Head, not produced block IReadOnlyTxProcessorSource readOnlyTxProcessorSourceForTxPriority = new ReadOnlyTxProcessingEnv(_api.DbProvider, _api.ReadOnlyTrieStore, _api.BlockTree, _api.SpecProvider, _api.LogManager); (_txPriorityContract, _localDataSource) = TxAuRaFilterBuilders.CreateTxPrioritySources(_auraConfig, _api, readOnlyTxProcessorSourceForTxPriority); if (_txPriorityContract != null || _localDataSource != null) { _minGasPricesContractDataStore = TxAuRaFilterBuilders.CreateMinGasPricesDataStore(_api, _txPriorityContract, _localDataSource) !; _api.DisposeStack.Push(_minGasPricesContractDataStore); ContractDataStore <Address> whitelistContractDataStore = new ContractDataStoreWithLocalData <Address>( new HashSetContractDataStoreCollection <Address>(), _txPriorityContract?.SendersWhitelist, _api.BlockTree, _api.ReceiptFinder, _api.LogManager, _localDataSource?.GetWhitelistLocalDataSource() ?? new EmptyLocalDataSource <IEnumerable <Address> >()); DictionaryContractDataStore <TxPriorityContract.Destination> prioritiesContractDataStore = new DictionaryContractDataStore <TxPriorityContract.Destination>( new TxPriorityContract.DestinationSortedListContractDataStoreCollection(), _txPriorityContract?.Priorities, _api.BlockTree, _api.ReceiptFinder, _api.LogManager, _localDataSource?.GetPrioritiesLocalDataSource()); _api.DisposeStack.Push(whitelistContractDataStore); _api.DisposeStack.Push(prioritiesContractDataStore); ITxFilter auraTxFilter = CreateAuraTxFilterForProducer(readOnlyTxProcessorSource, _api.SpecProvider); ITxFilterPipeline txFilterPipeline = new TxFilterPipelineBuilder(_api.LogManager) .WithCustomTxFilter(auraTxFilter) .WithBaseFeeFilter(_api.SpecProvider) .WithNullTxFilter() .Build; return(new TxPriorityTxSource( _api.TxPool, processingEnv.StateReader, _api.LogManager, txFilterPipeline, whitelistContractDataStore, prioritiesContractDataStore, _api.SpecProvider, _api.TransactionComparerProvider)); } else { return(CreateStandardTxPoolTxSource(processingEnv, readOnlyTxProcessorSource)); } }
protected override TxPoolTxSource CreateTxPoolTxSource() { TxPoolTxSource txPoolTxSource = base.CreateTxPoolTxSource(); TxPriorityContract = new TxPriorityContract(new AbiEncoder(), TestItem.AddressA, new ReadOnlyTxProcessorSource(DbProvider, BlockTree, SpecProvider, LimboLogs.Instance)); var comparer = TxPriorityContract.DestinationMethodComparer.Instance; Priorities = new SortedListContractDataStore <TxPriorityContract.Destination>(TxPriorityContract.Priorities, BlockProcessor, comparer); MinGasPrices = new DictionaryContractDataStore <TxPriorityContract.Destination>(TxPriorityContract.MinGasPrices, BlockProcessor, comparer); SendersWhitelist = new HashSetContractDataStore <Address>(TxPriorityContract.SendersWhitelist, BlockProcessor); return(txPoolTxSource); }
protected override TxPoolTxSource CreateTxPoolTxSource(ReadOnlyTxProcessingEnv processingEnv, ReadOnlyTxProcessorSource readOnlyTxProcessorSource) { // We need special one for TxPriority as its following Head separately with events and we want rules from Head, not produced block ReadOnlyTxProcessorSource readOnlyTxProcessorSourceForTxPriority = new ReadOnlyTxProcessorSource(_api.DbProvider, _api.BlockTree, _api.SpecProvider, _api.LogManager); (_txPriorityContract, _localDataSource) = TxFilterBuilders.CreateTxPrioritySources(_auraConfig, _api, readOnlyTxProcessorSourceForTxPriority); if (_txPriorityContract != null || _localDataSource != null) { _minGasPricesContractDataStore = TxFilterBuilders.CreateMinGasPricesDataStore(_api, _txPriorityContract, _localDataSource) !; _api.DisposeStack.Push(_minGasPricesContractDataStore); ContractDataStore <Address, IContractDataStoreCollection <Address> > whitelistContractDataStore = new ContractDataStoreWithLocalData <Address>( new HashSetContractDataStoreCollection <Address>(), _txPriorityContract?.SendersWhitelist, _api.BlockTree, _api.ReceiptFinder, _api.LogManager, _localDataSource?.GetWhitelistLocalDataSource() ?? new EmptyLocalDataSource <IEnumerable <Address> >()); DictionaryContractDataStore <TxPriorityContract.Destination, TxPriorityContract.DestinationSortedListContractDataStoreCollection> prioritiesContractDataStore = new DictionaryContractDataStore <TxPriorityContract.Destination, TxPriorityContract.DestinationSortedListContractDataStoreCollection>( new TxPriorityContract.DestinationSortedListContractDataStoreCollection(), _txPriorityContract?.Priorities, _api.BlockTree, _api.ReceiptFinder, _api.LogManager, _localDataSource?.GetPrioritiesLocalDataSource()); _api.DisposeStack.Push(whitelistContractDataStore); _api.DisposeStack.Push(prioritiesContractDataStore); return(new TxPriorityTxSource( _api.TxPool, processingEnv.StateReader, _api.LogManager, CreateTxSourceFilter(processingEnv, readOnlyTxProcessorSource), whitelistContractDataStore, prioritiesContractDataStore)); } else { return(base.CreateTxPoolTxSource(processingEnv, readOnlyTxProcessorSource)); } }