Exemplo n.º 1
0
        public static async Task DisposeInWalletDependentServicesAsync()
        {
            if (WalletService != null)
            {
                WalletService.Coins.CollectionChanged -= Coins_CollectionChanged;
            }
            CancelWalletServiceInitialization?.Cancel();
            CancelWalletServiceInitialization = null;

            if (!(WalletService is null))
            {
                if (!(WalletService.KeyManager is null))                 // This should not ever happen.
                {
                    string backupWalletFilePath = Path.Combine(WalletBackupsDir, Path.GetFileName(WalletService.KeyManager.FilePath));
                    WalletService.KeyManager?.ToFile(backupWalletFilePath);
                    Logger.LogInfo($"{nameof(KeyManager)} backup saved to {backupWalletFilePath}.", nameof(Global));
                }
                WalletService.Dispose();
                WalletService = null;
            }

            Logger.LogInfo($"{nameof(WalletService)} is stopped.", nameof(Global));

            if (!(ChaumianClient is null))
            {
                await ChaumianClient.StopAsync();

                ChaumianClient = null;
            }
            Logger.LogInfo($"{nameof(ChaumianClient)} is stopped.", nameof(Global));
        }
Exemplo n.º 2
0
        public static async Task DisposeAsync()
        {
            CancelWalletServiceInitialization?.Cancel();

            WalletService?.Dispose();
            Logger.LogInfo($"{nameof(WalletService)} is stopped.", nameof(Global));

            UpdateChecker?.Dispose();
            Logger.LogInfo($"{nameof(UpdateChecker)} is stopped.", nameof(Global));

            IndexDownloader?.Dispose();
            Logger.LogInfo($"{nameof(IndexDownloader)} is stopped.", nameof(Global));

            Directory.CreateDirectory(Path.GetDirectoryName(AddressManagerFilePath));
            AddressManager?.SavePeerFile(AddressManagerFilePath, Config.Network);
            Logger.LogInfo($"{nameof(AddressManager)} is saved to `{AddressManagerFilePath}`.", nameof(Global));

            Nodes?.Dispose();
            Logger.LogInfo($"{nameof(Nodes)} are disposed.", nameof(Global));

            if (RegTestMemPoolServingNode != null)
            {
                RegTestMemPoolServingNode.Disconnect();
                Logger.LogInfo($"{nameof(RegTestMemPoolServingNode)} is disposed.", nameof(Global));
            }

            if (ChaumianClient != null)
            {
                await ChaumianClient.StopAsync();
            }
            Logger.LogInfo($"{nameof(ChaumianClient)} is stopped.", nameof(Global));
        }
Exemplo n.º 3
0
        public static async Task DisposeInWalletDependentServicesAsync()
        {
            CancelWalletServiceInitialization?.Cancel();
            CancelWalletServiceInitialization = null;

            WalletService?.Dispose();
            WalletService = null;
            Logger.LogInfo($"{nameof(WalletService)} is stopped.", nameof(Global));

            if (ChaumianClient != null)
            {
                await ChaumianClient.StopAsync();

                ChaumianClient = null;
            }
            Logger.LogInfo($"{nameof(ChaumianClient)} is stopped.", nameof(Global));
        }
Exemplo n.º 4
0
        public async Task DisposeInWalletDependentServicesAsync()
        {
            if (WalletService != null)
            {
                WalletService.Coins.CollectionChanged -= Coins_CollectionChanged;
            }
            try
            {
                _cancelWalletServiceInitialization?.Cancel();
            }
            catch (ObjectDisposedException)
            {
                Logger.LogWarning($"{nameof(_cancelWalletServiceInitialization)} is disposed. This can occur due to an error while processing the wallet.", nameof(Global));
            }
            _cancelWalletServiceInitialization = null;

            if (WalletService != null)
            {
                if (WalletService.KeyManager != null)                 // This should not ever happen.
                {
                    string backupWalletFilePath = Path.Combine(WalletBackupsDir, Path.GetFileName(WalletService.KeyManager.FilePath));
                    WalletService.KeyManager?.ToFile(backupWalletFilePath);
                    Logger.LogInfo($"{nameof(KeyManager)} backup saved to `{backupWalletFilePath}`.", nameof(Global));
                }
                if (WalletService != null)
                {
                    await WalletService.StopAsync();
                }
                WalletService = null;
                Logger.LogInfo($"{nameof(WalletService)} is stopped.", nameof(Global));
            }

            if (ChaumianClient != null)
            {
                await ChaumianClient.StopAsync();

                ChaumianClient = null;
                Logger.LogInfo($"{nameof(ChaumianClient)} is stopped.", nameof(Global));
            }
        }