private void PublishStateToMqtt(IStateProvider provider) { if (provider != null) { TryCall(provider, item => _mqttService.Publish(item.StateTopic, item.State)); } }
protected override void GivenThat() { base.GivenThat(); _webClientFactory = GenerateMock <IWebClientFactory>(); _webClient = GenerateMock <IWebClient>(); _directoryInfoProvider = GenerateMock <IDirectoryInfoProvider>(); _directoryInfo = GenerateMock <IDirectoryInfo>(); _fileUtilities = GenerateMock <IFileUtilities>(); _stateProvider = GenerateMock <IStateProvider>(); _counterFactory = GenerateMock <ICounterFactory>(); _averageCounterTime = GenerateMock <IAverageCounter>(); _averageCounterSize = GenerateMock <IAverageCounter>(); _state = GenerateMock <IState>(); _commandExecuter = GenerateMock <ICommandExecuter>(); _syncItem = new SyncItem(); _exception = null; SetupData(); SetupStubs(); _downloader = new EpisodeDownloader(_webClientFactory, _directoryInfoProvider, _fileUtilities, _stateProvider, _counterFactory, _commandExecuter); _downloader.StatusUpdate += new EventHandler <StatusUpdateEventArgs>(DownloaderStatusUpdate); _downloader.ProgressUpdate += new EventHandler <ProgressEventArgs>(DownloaderProgressUpdate); }
public BlockchainBridge( IStateReader stateReader, IStateProvider stateProvider, IStorageProvider storageProvider, IBlockTree blockTree, ITxPool txPool, ITxPoolInfoProvider transactionPoolInfoProvider, IReceiptStorage receiptStorage, IFilterStore filterStore, IFilterManager filterManager, IWallet wallet, ITransactionProcessor transactionProcessor) { _stateReader = stateReader ?? throw new ArgumentNullException(nameof(stateReader)); _stateProvider = stateProvider ?? throw new ArgumentNullException(nameof(stateProvider)); _storageProvider = storageProvider ?? throw new ArgumentNullException(nameof(storageProvider)); _blockTree = blockTree ?? throw new ArgumentNullException(nameof(blockTree)); _txPool = txPool ?? throw new ArgumentNullException(nameof(_txPool)); _transactionPoolInfoProvider = transactionPoolInfoProvider ?? throw new ArgumentNullException(nameof(transactionPoolInfoProvider)); _receiptStorage = receiptStorage ?? throw new ArgumentNullException(nameof(receiptStorage)); _filterStore = filterStore ?? throw new ArgumentException(nameof(filterStore)); _filterManager = filterManager ?? throw new ArgumentException(nameof(filterManager)); _wallet = wallet ?? throw new ArgumentException(nameof(wallet)); _transactionProcessor = transactionProcessor ?? throw new ArgumentException(nameof(transactionProcessor)); }
public GameInputProcessor(UserCommandMapper mapper, IStateProvider provider, IFilteredInput input, IFilteredInput dummyInput) { _userCmdMapper = mapper; _userInput = input; _stateProvider = provider; _dummyUserInput = dummyInput; }
public MinedBlockProducer(ITxSource txSource, IBlockchainProcessor processor, ISealer sealer, IBlockTree blockTree, IBlockProcessingQueue blockProcessingQueue, IStateProvider stateProvider, IGasLimitCalculator gasLimitCalculator, ITimestamper timestamper, ISpecProvider specProvider, ILogManager logManager, IDifficultyCalculator difficultyCalculator) : base( txSource, processor, sealer, blockTree, blockProcessingQueue, stateProvider, gasLimitCalculator, timestamper, specProvider, logManager) { _difficultyCalculator = difficultyCalculator ?? throw new ArgumentNullException(nameof(difficultyCalculator)); }
public void Setup() { _dbProvider = new MemDbProvider(_logManager); _blockhashProvider = new TestBlockhashProvider(); _stateProvider = new StateProvider(new StateTree(_dbProvider.GetOrCreateStateDb()), _dbProvider.GetOrCreateCodeDb(), _logManager); _storageProvider = new StorageProvider(new MemDbProvider(_logManager), _stateProvider, _logManager); }
/// <summary> /// Given a provider name locate the necessary /// <see cref="AdoTrackingResourceAccessor" /> in the configuration file. /// </summary> /// <returns> /// An <see cref="AdoTrackingResourceAccessor" />. /// </returns> public static AdoTrackingResourceAccessor Create( IAdoResourceProvider resourceProvider, ITrackingNameResolver nameResolver, IAdoValueReader valueReader, Transaction transaction, IStateProvider stateProvider) { // locate any mappings for the specified provider ProviderNameTypeMapping mapping = TrackingAdoProviderSettings.Get() .ResourceAccessors.FindByProviderName(resourceProvider.ProviderName); AdoTrackingResourceAccessor resourceAccessor; if (mapping != null) { resourceAccessor = TypeUtilities.CreateInstance<AdoTrackingResourceAccessor>( mapping.Type, new object[] { resourceProvider, nameResolver, valueReader, transaction, stateProvider }); } else { return new AdoTrackingResourceAccessor( resourceProvider, nameResolver, valueReader, transaction, stateProvider); } return resourceAccessor; }
public CliqueBlockProducer(ITxPool txPool, IBlockchainProcessor blockchainProcessor, IBlockTree blockTree, ITimestamper timestamper, ICryptoRandom cryptoRandom, IStateProvider stateProvider, ISnapshotManager snapshotManager, ISealer cliqueSealer, Address address, ICliqueConfig config, ILogManager logManager) { _logger = logManager?.GetClassLogger() ?? throw new ArgumentNullException(nameof(logManager)); _txPool = txPool ?? throw new ArgumentNullException(nameof(txPool)); _processor = blockchainProcessor ?? throw new ArgumentNullException(nameof(blockchainProcessor)); _blockTree = blockTree ?? throw new ArgumentNullException(nameof(blockTree)); _stateProvider = stateProvider ?? throw new ArgumentNullException(nameof(stateProvider)); _timestamper = timestamper ?? throw new ArgumentNullException(nameof(timestamper)); _cryptoRandom = cryptoRandom ?? throw new ArgumentNullException(nameof(cryptoRandom)); _sealer = cliqueSealer ?? throw new ArgumentNullException(nameof(cliqueSealer)); _snapshotManager = snapshotManager ?? throw new ArgumentNullException(nameof(snapshotManager)); _config = config ?? throw new ArgumentNullException(nameof(config)); _address = address ?? throw new ArgumentNullException(nameof(address)); _wiggle = new WiggleRandomizer(_cryptoRandom, _snapshotManager); _timer.AutoReset = false; _timer.Elapsed += TimerOnElapsed; _timer.Interval = 100; _timer.Start(); }
public UserOperationSimulator( IUserOperationTxBuilder userOperationTxBuilder, IStateProvider stateProvider, IStateReader stateReader, AbiDefinition entryPointContractAbi, Address create2FactoryAddress, Address entryPointContractAddress, ISpecProvider specProvider, IBlockTree blockTree, IDbProvider dbProvider, IReadOnlyTrieStore trieStore, ITimestamper timestamper, ILogManager logManager) { _userOperationTxBuilder = userOperationTxBuilder; _stateProvider = stateProvider; _stateReader = stateReader; _entryPointContractAbi = entryPointContractAbi; _create2FactoryAddress = create2FactoryAddress; _entryPointContractAddress = entryPointContractAddress; _specProvider = specProvider; _blockTree = blockTree; _dbProvider = dbProvider.AsReadOnly(false); _trieStore = trieStore; _timestamper = timestamper; _logManager = logManager; _abiEncoder = new AbiEncoder(); }
public AuRaBlockProducer(ITxSource txSource, IBlockchainProcessor processor, IBlockProductionTrigger blockProductionTrigger, IStateProvider stateProvider, ISealer sealer, IBlockTree blockTree, ITimestamper timestamper, IAuRaStepCalculator auRaStepCalculator, IReportingValidator reportingValidator, IAuraConfig config, IGasLimitCalculator gasLimitCalculator, ISpecProvider specProvider, ILogManager logManager) : base( txSource, processor, sealer, blockTree, blockProductionTrigger, stateProvider, gasLimitCalculator, timestamper, specProvider, logManager, new AuraDifficultyCalculator(auRaStepCalculator)) { _auRaStepCalculator = auRaStepCalculator ?? throw new ArgumentNullException(nameof(auRaStepCalculator)); _reportingValidator = reportingValidator ?? throw new ArgumentNullException(nameof(reportingValidator)); _config = config ?? throw new ArgumentNullException(nameof(config)); }
protected async Task Prepare() { _wallet = new DevWallet(new WalletConfig(), _logManager); _feeAccount = _wallet.GetAccounts()[0]; _consumerAccount = _wallet.GetAccounts()[1]; _providerAccount = _wallet.GetAccounts()[2]; _ndmConfig = new NdmConfig(); IReleaseSpec spec = _releaseSpec; ISpecProvider specProvider = new SingleReleaseSpecProvider(spec, 99); MemDb stateDb = new MemDb(); TrieStore trieStore = new TrieStore(stateDb, _logManager); _state = new StateProvider(trieStore, new MemDb(), _logManager); StorageProvider storageProvider = new StorageProvider(trieStore, _state, _logManager); _state.CreateAccount(_consumerAccount, 1000.Ether()); _state.CreateAccount(_providerAccount, 1.Ether()); _state.Commit(spec); _state.CommitTree(0); VirtualMachine machine = new VirtualMachine(_state, storageProvider, Substitute.For <IBlockhashProvider>(), specProvider, _logManager); TransactionProcessor processor = new TransactionProcessor(specProvider, _state, storageProvider, machine, _logManager); _bridge = new BlockchainBridge(processor); TxReceipt receipt = await DeployContract(Bytes.FromHexString(ContractData.GetInitCode(_feeAccount))); ((NdmConfig)_ndmConfig).ContractAddress = receipt.ContractAddress.ToString(); _contractAddress = receipt.ContractAddress; _txPool = new TxPool.TxPool(new InMemoryTxStorage(), new EthereumEcdsa(specProvider.ChainId, _logManager), new FixedBlockChainHeadSpecProvider(specProvider), new TxPoolConfig(), _state, new TxValidator(specProvider.ChainId), _logManager); _ndmBridge = new NdmBlockchainBridge(_bridge, _bridge, _bridge, _bridge); }
protected LoopBlockProducerBase( ITxSource txSource, IBlockchainProcessor processor, ISealer sealer, IBlockTree blockTree, IBlockProcessingQueue blockProcessingQueue, IStateProvider stateProvider, ITimestamper timestamper, IGasLimitCalculator gasLimitCalculator, ISpecProvider specProvider, ILogManager logManager, string name) : base( txSource, processor, sealer, blockTree, blockProcessingQueue, stateProvider, gasLimitCalculator, timestamper, specProvider, logManager) { _name = name; }
internal static void Init(IStateProvider provider) { if (provider == null) return; StateProvider = provider; }
public PendingTxSelector(ITxPool transactionPool, IStateProvider stateProvider, ILogManager logManager, long minGasPriceForMining = 1) { _transactionPool = transactionPool ?? throw new ArgumentNullException(nameof(transactionPool)); _stateProvider = stateProvider ?? throw new ArgumentNullException(nameof(stateProvider)); _logger = logManager?.GetClassLogger <PendingTxSelector>() ?? throw new ArgumentNullException(nameof(logManager)); _minGasPriceForMining = minGasPriceForMining; }
public static TrieStats CollectStats(this IStateProvider stateProvider, IKeyValueStore codeStorage, ILogManager logManager) { TrieStatsCollector collector = new TrieStatsCollector(codeStorage, logManager); stateProvider.Accept(collector, stateProvider.StateRoot); return(collector.Stats); }
public static string DumpState(this IStateProvider stateProvider) { TreeDumper dumper = new TreeDumper(); stateProvider.Accept(dumper, stateProvider.StateRoot); return(dumper.ToString()); }
public Context() { StateProvider = new StateProvider(new TrieStore(new MemDb(), LimboLogs.Instance), Substitute.For <IDb>(), LogManager); StateProvider.CreateAccount(Address1, 0); StateProvider.CreateAccount(Address2, 0); StateProvider.Commit(Frontier.Instance); }
public Ledger(IDeltaExecutor deltaExecutor, IStateProvider stateProvider, IStorageProvider storageProvider, ISnapshotableDb stateDb, ISnapshotableDb codeDb, IAccountRepository accounts, IDeltaHashProvider deltaHashProvider, ILedgerSynchroniser synchroniser, IMempool <PublicEntryDao> mempool, IMapperProvider mapperProvider, ILogger logger) { Accounts = accounts; _deltaExecutor = deltaExecutor; _stateProvider = stateProvider; _storageProvider = storageProvider; _stateDb = stateDb; _codeDb = codeDb; _synchroniser = synchroniser; _mempool = mempool; _mapperProvider = mapperProvider; _logger = logger; _deltaUpdatesSubscription = deltaHashProvider.DeltaHashUpdates.Subscribe(Update); LatestKnownDelta = _synchroniser.DeltaCache.GenesisHash; }
public AuRaValidatorFactory(IStateProvider stateProvider, IAbiEncoder abiEncoder, ITransactionProcessor transactionProcessor, IReadOnlyTxProcessorSource readOnlyTxProcessorSource, IBlockTree blockTree, IReceiptFinder receiptFinder, IValidatorStore validatorStore, IBlockFinalizationManager finalizationManager, ITxSender txSender, ITxPool txPool, IMiningConfig miningConfig, ILogManager logManager, ISigner signer, ReportingContractBasedValidator.Cache reportingValidatorCache, long posdaoTransition, bool forSealing = false) { _stateProvider = stateProvider; _abiEncoder = abiEncoder; _transactionProcessor = transactionProcessor; _readOnlyTxProcessorSource = readOnlyTxProcessorSource; _blockTree = blockTree; _receiptFinder = receiptFinder; _validatorStore = validatorStore; _finalizationManager = finalizationManager; _txSender = txSender; _txPool = txPool; _miningConfig = miningConfig; _logManager = logManager; _signer = signer; _reportingValidatorCache = reportingValidatorCache; _posdaoTransition = posdaoTransition; _forSealing = forSealing; }
public BlockchainBridge( IStateReader stateReader, IStateProvider stateProvider, IStorageProvider storageProvider, IBlockTree blockTree, ITxPool txPool, IReceiptFinder receiptStorage, IFilterStore filterStore, IFilterManager filterManager, IWallet wallet, ITransactionProcessor transactionProcessor, IEthereumEcdsa ecdsa, IBloomStorage bloomStorage, ILogManager logManager, bool isMining, int findLogBlockDepthLimit = 1000) { _stateReader = stateReader ?? throw new ArgumentNullException(nameof(stateReader)); _stateProvider = stateProvider ?? throw new ArgumentNullException(nameof(stateProvider)); _storageProvider = storageProvider ?? throw new ArgumentNullException(nameof(storageProvider)); _blockTree = blockTree ?? throw new ArgumentNullException(nameof(blockTree)); _txPool = txPool ?? throw new ArgumentNullException(nameof(_txPool)); _receiptFinder = receiptStorage ?? throw new ArgumentNullException(nameof(receiptStorage)); _filterStore = filterStore ?? throw new ArgumentException(nameof(filterStore)); _filterManager = filterManager ?? throw new ArgumentException(nameof(filterManager)); _wallet = wallet ?? throw new ArgumentException(nameof(wallet)); _transactionProcessor = transactionProcessor ?? throw new ArgumentException(nameof(transactionProcessor)); _ecdsa = ecdsa ?? throw new ArgumentNullException(nameof(ecdsa)); IsMining = isMining; _logFinder = new LogFinder(_blockTree, _receiptFinder, bloomStorage, logManager, new ReceiptsRecovery(), findLogBlockDepthLimit); }
private void InitializeTestState(BlockchainTest test, IStateProvider stateProvider, IStorageProvider storageProvider, ISpecProvider specProvider) { foreach (KeyValuePair <Address, AccountState> accountState in test.Pre) { foreach (KeyValuePair <UInt256, byte[]> storageItem in accountState.Value.Storage) { storageProvider.Set(new StorageAddress(accountState.Key, storageItem.Key), storageItem.Value); } stateProvider.CreateAccount(accountState.Key, accountState.Value.Balance); Keccak codeHash = stateProvider.UpdateCode(accountState.Value.Code); stateProvider.UpdateCodeHash(accountState.Key, codeHash, specProvider.GenesisSpec); for (int i = 0; i < accountState.Value.Nonce; i++) { stateProvider.IncrementNonce(accountState.Key); } } storageProvider.Commit(); stateProvider.Commit(specProvider.GenesisSpec); storageProvider.CommitTrees(); stateProvider.CommitTree(); storageProvider.Reset(); stateProvider.Reset(); }
public ProductScoreCalculator(IContextProvider contextProvider, IStateProvider stateProvider) { _usersApi = new UsersApi(contextProvider); _catalogsApi = new CatalogsApi(contextProvider); _userCatalogProvider = new UserCatalogProvider(contextProvider, stateProvider); }
public UserCatalogProvider(IContextProvider contextProvider, IStateProvider stateProvider) { _catalogsApi = new CatalogsApi(contextProvider); _catalogsRepository = new CatalogsRepository(); _createCatalogFlow = new CreateCatalogFlow(contextProvider, stateProvider); }
public void SetUp() { _db = Substitute.For <IDb>(); _db[ContractValidator.PendingValidatorsKey.Bytes].Returns((byte[])null); _stateProvider = Substitute.For <IStateProvider>(); _abiEncoder = Substitute.For <IAbiEncoder>(); _logManager = Substitute.For <ILogManager>(); _blockTree = Substitute.For <IBlockTree>(); _blockFinalizationManager = Substitute.For <IBlockFinalizationManager>(); _receiptsStorage = Substitute.For <IReceiptStorage>(); _validator = new AuRaParameters.Validator() { Addresses = new[] { _contractAddress }, ValidatorType = AuRaParameters.ValidatorType.Contract }; _block = new Block(Prepare.A.BlockHeader().WithNumber(1).WithAura(1, Bytes.Empty).TestObject, new BlockBody()); _transactionProcessor = Substitute.For <ITransactionProcessor>(); _abiEncoder .Encode(AbiEncodingStyle.IncludeSignature, Arg.Is <AbiSignature>(s => s.Name == "getValidators"), Arg.Any <object[]>()) .Returns(_getValidatorsData); _abiEncoder .Encode(AbiEncodingStyle.IncludeSignature, Arg.Is <AbiSignature>(s => s.Name == "finalizeChange"), Arg.Any <object[]>()) .Returns(_finalizeChangeData); }
public CreateCatalogFlow(IContextProvider contextProvider, IStateProvider stateProvider) { _catalogsApi = new CatalogsApi(contextProvider); _userContextProvider = new UserContextProvider(stateProvider, contextProvider); _catalogsRepository = new CatalogsRepository(); }
public UserContextProvider( IStateProvider stateProvider, IContextProvider contextProvider) { _usersApi = new UsersApi(contextProvider); _stateProvider = stateProvider; }
public Tracer( IStateProvider stateProvider, IBlockchainProcessor blockProcessor) { _stateProvider = stateProvider ?? throw new ArgumentNullException(nameof(stateProvider)); _blockProcessor = blockProcessor ?? throw new ArgumentNullException(nameof(blockProcessor)); }
public TxPermissionFilter(VersionedContract <TransactionPermissionContract> contract, ITxPermissionFilter.Cache cache, IStateProvider stateProvider, ILogManager logManager) { _contract = contract ?? throw new ArgumentNullException(nameof(contract)); _cache = cache ?? throw new ArgumentNullException(nameof(cache)); _stateProvider = stateProvider ?? throw new ArgumentNullException(nameof(stateProvider)); _logger = logManager?.GetClassLogger <TxPermissionFilter>() ?? throw new ArgumentNullException(nameof(logManager)); }
public ContractBasedValidator( AuRaParameters.Validator validator, IStateProvider stateProvider, IAbiEncoder abiEncoder, ITransactionProcessor transactionProcessor, IReadOnlyTransactionProcessorSource readOnlyTransactionProcessorSource, IBlockTree blockTree, IReceiptFinder receiptFinder, IValidatorStore validatorStore, IValidSealerStrategy validSealerStrategy, ILogManager logManager, long startBlockNumber) : base(validator, validSealerStrategy, logManager) { _blockTree = blockTree ?? throw new ArgumentNullException(nameof(blockTree)); ContractAddress = validator.Addresses?.FirstOrDefault() ?? throw new ArgumentException("Missing contract address for AuRa validator.", nameof(validator.Addresses)); _stateProvider = stateProvider ?? throw new ArgumentNullException(nameof(stateProvider)); _transactionProcessor = transactionProcessor ?? throw new ArgumentNullException(nameof(transactionProcessor)); _readOnlyReadOnlyTransactionProcessorSource = readOnlyTransactionProcessorSource ?? throw new ArgumentNullException(nameof(readOnlyTransactionProcessorSource)); _receiptFinder = receiptFinder ?? throw new ArgumentNullException(nameof(receiptFinder)); _validatorStore = validatorStore ?? throw new ArgumentNullException(nameof(validatorStore)); _logger = logManager?.GetClassLogger() ?? throw new ArgumentNullException(nameof(logManager)); AbiEncoder = abiEncoder ?? throw new ArgumentNullException(nameof(abiEncoder)); InitBlockNumber = startBlockNumber; SetPendingValidators(LoadPendingValidators()); }
public void Start(IStateProvider state) { callback = state; sendEvent = true; SendState(); }
public AuRaBlockProducer(ITxSource txSource, IBlockchainProcessor processor, IStateProvider stateProvider, ISealer sealer, IBlockTree blockTree, IBlockProcessingQueue blockProcessingQueue, ITimestamper timestamper, IAuRaStepCalculator auRaStepCalculator, IReportingValidator reportingValidator, IAuraConfig config, IGasLimitCalculator gasLimitCalculator, ISpecProvider specProvider, ILogManager logManager) : base( new ValidatedTxSource(txSource, logManager), processor, sealer, blockTree, blockProcessingQueue, stateProvider, timestamper, gasLimitCalculator, specProvider, logManager, "AuRa") { _auRaStepCalculator = auRaStepCalculator ?? throw new ArgumentNullException(nameof(auRaStepCalculator)); _reportingValidator = reportingValidator ?? throw new ArgumentNullException(nameof(reportingValidator)); _config = config ?? throw new ArgumentNullException(nameof(config)); _canProduce = _config.AllowAuRaPrivateChains ? 1 : 0; }
public void Setup() { _address = Address.FromNumber(1); _stateProvider = Substitute.For <IStateProvider>(); _txPool = Substitute.For <ITxPool>(); _infoProvider = new TxPoolInfoProvider(_stateProvider, _txPool); }
protected void Prepare() { _wallet = new DevWallet(new WalletConfig(), _logManager); _feeAccount = _wallet.GetAccounts()[0]; _consumerAccount = _wallet.GetAccounts()[1]; _providerAccount = _wallet.GetAccounts()[2]; _ndmConfig = new NdmConfig(); IReleaseSpec spec = _releaseSpec; ISpecProvider specProvider = new SingleReleaseSpecProvider(spec, 99); StateDb stateDb = new StateDb(); _state = new StateProvider(stateDb, new StateDb(), _logManager); StorageProvider storageProvider = new StorageProvider(stateDb, _state, _logManager); _state.CreateAccount(_consumerAccount, 1000.Ether()); _state.CreateAccount(_providerAccount, 1.Ether()); _state.Commit(spec); _state.CommitTree(); VirtualMachine machine = new VirtualMachine(_state, storageProvider, Substitute.For <IBlockhashProvider>(), _logManager); TransactionProcessor processor = new TransactionProcessor(specProvider, _state, storageProvider, machine, _logManager); _bridge = new BlockchainBridge(processor, _releaseSpec); TxReceipt receipt = DeployContract(Bytes.FromHexString(ContractData.GetInitCode(_feeAccount))); _ndmConfig.ContractAddress = receipt.ContractAddress.ToString(); }
public BlockProcessor( ISpecProvider specProvider, IBlockValidator blockValidator, IRewardCalculator rewardCalculator, ITransactionProcessor transactionProcessor, ISnapshotableDb stateDb, ISnapshotableDb codeDb, IStateProvider stateProvider, IStorageProvider storageProvider, ITxPool txPool, IReceiptStorage receiptStorage, ILogManager logManager) { _logger = logManager?.GetClassLogger() ?? throw new ArgumentNullException(nameof(logManager)); _specProvider = specProvider ?? throw new ArgumentNullException(nameof(specProvider)); _blockValidator = blockValidator ?? throw new ArgumentNullException(nameof(blockValidator)); _stateProvider = stateProvider ?? throw new ArgumentNullException(nameof(stateProvider)); _storageProvider = storageProvider ?? throw new ArgumentNullException(nameof(storageProvider)); _txPool = txPool ?? throw new ArgumentNullException(nameof(txPool)); _receiptStorage = receiptStorage ?? throw new ArgumentNullException(nameof(receiptStorage)); _rewardCalculator = rewardCalculator ?? throw new ArgumentNullException(nameof(rewardCalculator)); _transactionProcessor = transactionProcessor ?? throw new ArgumentNullException(nameof(transactionProcessor)); _stateDb = stateDb ?? throw new ArgumentNullException(nameof(stateDb)); _codeDb = codeDb ?? throw new ArgumentNullException(nameof(codeDb)); _receiptsTracer = new BlockReceiptsTracer(); }
public BlockchainBridge( ReadOnlyTxProcessingEnv processingEnv, ITxPool txPool, IReceiptFinder receiptStorage, IFilterStore filterStore, IFilterManager filterManager, IEthereumEcdsa ecdsa, ITimestamper timestamper, ILogFinder logFinder, bool isMining, bool isBeamSyncing) { _processingEnv = processingEnv ?? throw new ArgumentNullException(nameof(processingEnv)); _stateReader = processingEnv.StateReader ?? throw new ArgumentNullException(nameof(processingEnv.StateReader)); _stateProvider = processingEnv.StateProvider ?? throw new ArgumentNullException(nameof(processingEnv.StateProvider)); _blockTree = processingEnv.BlockTree ?? throw new ArgumentNullException(nameof(processingEnv.BlockTree)); _transactionProcessor = processingEnv.TransactionProcessor ?? throw new ArgumentNullException(nameof(processingEnv.TransactionProcessor)); _txPool = txPool ?? throw new ArgumentNullException(nameof(_txPool)); _receiptFinder = receiptStorage ?? throw new ArgumentNullException(nameof(receiptStorage)); _filterStore = filterStore ?? throw new ArgumentNullException(nameof(filterStore)); _filterManager = filterManager ?? throw new ArgumentNullException(nameof(filterManager)); _ecdsa = ecdsa ?? throw new ArgumentNullException(nameof(ecdsa)); _timestamper = timestamper ?? throw new ArgumentNullException(nameof(timestamper)); _logFinder = logFinder ?? throw new ArgumentNullException(nameof(logFinder)); _isBeamSyncing = isBeamSyncing; IsMining = isMining; }
public CatalogItemsFlow(IContextProvider contextProvider, IStateProvider stateProvider) { _userContextProvider = new UserContextProvider(stateProvider, contextProvider); _userCatalogProvider = new UserCatalogProvider(contextProvider, stateProvider); _catalogItemsApi = new CatalogItemsApi(contextProvider); }
public void Setup() { _stateProvider = new StateProvider(new StateDb(new MemDb()), Substitute.For <IDb>(), LogManager); _stateProvider.CreateAccount(_address1, 0); _stateProvider.CreateAccount(_address2, 0); _stateProvider.Commit(Frontier.Instance); }
public DashboardFlow(IContextProvider contextProvider, IStateProvider stateProvider) { _userContextProvider = new UserContextProvider(stateProvider, contextProvider); _productsApi = new ProductsApi(contextProvider); _productsRepository = new ProductsRepository(); _userCatalogProvider = new UserCatalogProvider(contextProvider, stateProvider); }
public EntityContextProvider(IEntityProvider entityProvider, IStateProvider stateProvider, ICryptoService cryptoService) { _entityProvider = entityProvider; _entityContext = stateProvider.CookieState("authctx", TimeSpan.Zero, false, true) .Signed(cryptoService, TimeSpan.Zero) .Jsoned<EntityContext>(); }
public PrecalculatedDashboardFlow(IContextProvider contextProvider, IStateProvider stateProvider) { _productScoreCalculator = new ProductScoreCalculator(contextProvider, stateProvider); _offlineTokenProvider = new OfflineTokenProvider(contextProvider); _platformTokenProvider = new PlatformTokenProvider(contextProvider); _catalogsRepository = new CatalogsRepository(); _productsRepository = new ProductsRepository(); }
private static async Task<ISequence> CreateSequence(IStateProvider stateProvider, int increment = 1, int startAt = 0, long maxValue = long.MaxValue, long minValue = long.MinValue,bool cycle = false ) { var options = new SequenceOptions { Increment = increment, StartAt = startAt, MaxValue = maxValue, Cycle = cycle, MinValue = minValue }; var sequence = await stateProvider.NewAsync(options); return sequence; }
public void Given_() { ctx = new TestSchedulerContext(); state = ctx.State; var _item = WorkItemFactory.Create(ctx); // Make item think that now tomorrow, so // it became applicable for scheduling ctx.MoveToTommorrow(); _item.UpdateState(); _item.Run(); // and .. wait until it will complete Wait.Until(() => _item.Status == JobStatus.Pending); }
internal SuspensionManager(IStateProvider stateProvider, IAdapterPlugin plugin) { if (stateProvider == null) throw new ArgumentNullException("stateProvider"); if (plugin == null) throw new AggregateException("plugin"); _stateProvider = stateProvider; _plugin = plugin; BuildDefaultStrategies(); _disposing = SuspendFixtureStrategy; _error = SuspendFixtureStrategy; _disconnected = SuspendFixtureStrategy; _default = SuspendFixtureStrategy; _fixtureDeleted = SuspendFixtureAndSetMatchStatusDeleted; }
private static void SwitchMode(IStateProvider currentModeState, IStateProvider newModeState) { bool isPlaying = currentModeState.IsPlaying; currentModeState.IsPlaying = false; Deactivate(currentModeState); newModeState.IsPlaying = isPlaying; if(!IsCompositionRunning) Activate(newModeState); }
public GraphChromatogram(IStateProvider stateProvider, IDocumentUIContainer documentContainer, string name) { InitializeComponent(); graphControl.GraphPane = new MSGraphPane(); _graphHelper = GraphHelper.Attach(graphControl); NameSet = name; Icon = Resources.SkylineData; _nameChromatogramSet = name; _documentContainer = documentContainer; _documentContainer.ListenUI(OnDocumentUIChanged); _stateProvider = stateProvider; // Synchronize the zooming across all graph panes // Note that this only affects applying ZoomState to a graph pane. Explicit changes // to Scale Min/Max properties need to be manually applied to each axis. graphControl.IsSynchronizeXAxes = true; }
/// <summary> /// Construct a new <see cref="OdpTrackingResourceAccessor" /> with the /// specified <see cref="IAdoResourceProvider" />, /// <see cref="ITrackingNameResolver" />, <see cref="IAdoValueReader" /> /// and <see cref="IStateProvider" />. All work should be performed in /// the specified <see cref="Transaction" />. /// </summary> /// <param name="resourceProvider"> /// An <see cref="IAdoResourceProvider" /> used to provide resources for /// accessing the tracking store. /// </param> /// <param name="nameResolver"> /// An <see cref="ITrackingNameResolver" /> that resolves names /// of commands and parameters for the relevant tracking store. /// </param> /// <param name="valueReader"> /// An <see cref="IAdoValueReader" /> that reads values from /// <see cref="IDbCommand" /> and <see cref="IDataReader" /> implementations. /// </param> /// <param name="transaction"> /// An <see cref="Transaction" /> in which to perform the work. /// </param> /// <param name="stateProvider"> /// An <see cref="IStateProvider" /> that can be used to store state. /// </param> /// </summary> public OdpTrackingResourceAccessor(IAdoResourceProvider resourceProvider, ITrackingNameResolver nameResolver, IAdoValueReader valueReader, Transaction transaction, IStateProvider stateProvider) : base(resourceProvider, nameResolver, valueReader, transaction, stateProvider) { }
public StockTrader Given_new_trader() { _stateProvider = new StateProvider(); return new StockTrader(_stateProvider); }
public SequenceGenerator(IStateProvider stateProvider) { if (stateProvider == null) throw new ArgumentNullException("stateProvider"); StateProvider = stateProvider; }
internal StatePersistor(string filePath, IStateProvider stateProvider) { this.filePath = filePath; this.stateProvider = stateProvider; }
public void Reset(TimeSpan totalGameTime, HelicopterScenario scenario, NavigationMap heightmap) { Console.WriteLine(@"Resetting helicopter."); _scenario = scenario; // TODO We would rather want to do Autopilot.Reset() than this fugly code Autopilot.IsAtDestination = false; Autopilot = Autopilot.Clone(); Autopilot.Task = scenario.Task.Clone(); Autopilot.Map = heightmap; Vector3 startPosition = scenario.StartPosition; Vector3 startVelocity = Vector3.Zero; Vector3 startAcceleration = Vector3.Zero; Quaternion startOrientation = Quaternion.Identity; if (Task.HoldHeightAboveGround > 0) startPosition.Y = Autopilot.Map.GetAltitude(VectorHelper.ToHorizontal(startPosition)) + Task.HoldHeightAboveGround; var startPhysicalState = new PhysicalHeliState( startOrientation, startPosition, startVelocity, startAcceleration); var initialState = new SimulationStepResults(startPhysicalState, totalGameTime); _physicalState = startPhysicalState; // Re-create the state provider when resetting because some sensors will have to re-initialize. _physics = new HeliPhysics(_collision, UseTerrainCollision); _sensors = new SensorModel(_sensorSpecifications, Autopilot.Map, startPosition, startOrientation); _perfectStateProvider = new PerfectState(); _estimatedStateProvider = new SensorEstimatedState(_sensors, startPhysicalState); // Wait for state to become stable. // while (!_perfectStateProvider.Ready) // { // TODO GPS will require N seconds of startup time // _perfectStateProvider.Update(initialState, 0, 0, new JoystickOutput()); // Sensors.Update(initialState, new JoystickOutput()); // Thread.Sleep(100); // } // When resetting, use perfect state as starting point. // TODO It should not be necessary to create this waypoint since it should never be used for navigation! Delete if safe. // Use start position and start orientation instead. const float defaultWaypointRadius = 5; var startWaypoint = new Waypoint(startPosition, 0, WaypointType.Intermediate, defaultWaypointRadius); _trueState = StateHelper.ToHeliState(startPhysicalState, GetHeightAboveGround(startPhysicalState.Position), startWaypoint, new JoystickOutput()); _estimatedState = _trueState; Log.Clear(); }
public StockTrader(IStateProvider stateProvider) { _stateProvider = stateProvider; }