private InherenceSetting CreateO10Inherence() { _logger.Info("CreateO10Inherence"); AccountId = _accountsService.Create(AccountType.ServiceProvider, nameof(O10InherenceService), GetDefaultO10InherencePassword(), true); InherenceSetting inherenceSetting = _dataAccessService.AddInherenceSetting(Name, AccountId); _logger.LogIfDebug(() => $"[{AccountId}]: {nameof(CreateO10Inherence)} account created"); return(inherenceSetting); }
public void Initialize(CancellationToken cancellationToken) { _logger.Info($"Initializing {nameof(O10InherenceService)}"); InherenceSetting inherenceSetting = _dataAccessService.GetInherenceSetting(Name); if (inherenceSetting == null) { inherenceSetting = CreateO10Inherence(); } AccountId = inherenceSetting.AccountId; _logger.LogIfDebug(() => $"[{AccountId}]: {nameof(Initialize)} proceeding"); AccountDescriptor accountDescriptor = _accountsService.GetById(inherenceSetting.AccountId); if (accountDescriptor == null) { _dataAccessService.RemoveInherenceSetting(Name); inherenceSetting = CreateO10Inherence(); accountDescriptor = _accountsService.Authenticate(inherenceSetting.AccountId, GetDefaultO10InherencePassword()); if (accountDescriptor == null) { throw new Exception($"{nameof(O10InherenceService)} initialization failed"); } } else { accountDescriptor = _accountsService.Authenticate(inherenceSetting.AccountId, GetDefaultO10InherencePassword()); } _logger.Info($"[{AccountId}]: Invoking InitializeStateExecutionServices"); _executionContextManager .InitializeStateExecutionServices( accountDescriptor.AccountId, accountDescriptor.SecretSpendKey, new Func <long, IStateTransactionsService, IStateClientCryptoService, CancellationToken, IUpdater>( (accountId, stateTransactionsService, stateClientSryptoService, ct) => { _clientCryptoService = stateClientSryptoService; return(this); })); Target = accountDescriptor.PublicSpendKey.ToHexString(); cancellationToken.Register(() => { _executionContextManager.UnregisterExecutionServices(AccountId); }); }