public void UnregisterExecutionServices(ulong accountId) { if (_statePersistencyItems.ContainsKey(accountId)) { StatePersistency persistency = _statePersistencyItems[accountId]; persistency.CancellationTokenSource.Cancel(); persistency.WalletSynchronizer.Dispose(); _statePersistencyItems.Remove(accountId); persistency.TransactionsService = null; persistency.WalletSynchronizer = null; persistency.ClientCryptoService = null; } else if (_utxoPersistencyItems.ContainsKey(accountId)) { UtxoPersistency persistency = _utxoPersistencyItems[accountId]; persistency.CancellationTokenSource.Cancel(); persistency.WalletSynchronizer.Dispose(); _utxoPersistencyItems.Remove(accountId); persistency.TransactionsService = null; persistency.WalletSynchronizer = null; persistency.ClientCryptoService = null; } }
public void InitializeUtxoExecutionServices(ulong accountId, byte[] secretSpendKey, byte[] secretViewKey, byte[] pwdSecretKey) { if (_utxoPersistencyItems.ContainsKey(accountId)) { return; } IPacketsProvider packetsProvider = ServiceLocator.Current.GetInstance <IPacketsProvider>(); IUtxoTransactionsService transactionsService = ServiceLocator.Current.GetInstance <UtxoTransactionsService>(); IUtxoClientCryptoService clientCryptoService = ServiceLocator.Current.GetInstance <UtxoClientCryptoService>(); UtxoWalletSynchronizer walletSynchronizer = ServiceLocator.Current.GetInstance <UtxoWalletSynchronizer>(); CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(); packetsProvider.Initialize(accountId, cancellationTokenSource.Token); clientCryptoService.Initialize(secretSpendKey, secretViewKey, pwdSecretKey); transactionsService.Initialize(clientCryptoService); transactionsService.PipeOutTransactions.LinkTo(_gatewayService.PipeInTransactions); transactionsService.PipeOutKeyImages.LinkTo(walletSynchronizer.PipeInKeyImages); UserIdentitiesUpdater userIdentitiesUpdater = new UserIdentitiesUpdater(accountId, clientCryptoService, _assetsService, _dataAccessService, _identitiesHubContext, _relationsProofsValidationService, _trackingService); walletSynchronizer.Initialize(accountId, clientCryptoService, _gatewayService, cancellationTokenSource.Token); packetsProvider.PipeOut.LinkTo(walletSynchronizer.PipeIn); walletSynchronizer.PipeOut.LinkTo(userIdentitiesUpdater.PipeIn); walletSynchronizer.Start(); packetsProvider.Start(); AddSubscriberToDictionary(accountId, walletSynchronizer.Subscribe(userIdentitiesUpdater)); var state = new UtxoPersistency { AccountId = accountId, PacketsProvider = packetsProvider, TransactionsService = transactionsService, ClientCryptoService = clientCryptoService, WalletSynchronizer = walletSynchronizer, CancellationTokenSource = cancellationTokenSource }; _utxoPersistencyItems.Add(accountId, state); }
public UtxoPersistency ResolveUtxoExecutionServices(ulong accountId) { UtxoPersistency utxoPersistency = _utxoPersistencyItems[accountId]; return(utxoPersistency); }