Пример #1
0
        private async void IndexDownloader_NewFilterAsync(object sender, FilterModel filterModel)
        {
            try
            {
                using (await HandleFiltersLock.LockAsync())
                {
                    if (KeyManager.GetBestHeight() < filterModel.Header.Height)
                    {
                        await ProcessFilterModelAsync(filterModel, CancellationToken.None);
                    }
                }
                NewFilterProcessed?.Invoke(this, filterModel);

                do
                {
                    await Task.Delay(100);

                    if (Synchronizer is null || BitcoinStore?.SmartHeaderChain is null)
                    {
                        return;
                    }
                    // Make sure fully synced and this filter is the lastest filter.
                    if (BitcoinStore.SmartHeaderChain.HashesLeft != 0 || BitcoinStore.SmartHeaderChain.TipHash != filterModel.Header.BlockHash)
                    {
                        return;
                    }
                } while (Synchronizer.AreRequestsBlocked());                 // If requests are blocked, delay mempool cleanup, because coinjoin answers are always priority.

                await BitcoinStore.MempoolService?.TryPerformMempoolCleanupAsync(Synchronizer?.WasabiClient?.TorClient?.DestinationUriAction, Synchronizer?.WasabiClient?.TorClient?.TorSocks5EndPoint);
            }
            catch (Exception ex)
            {
                Logger.LogWarning(ex);
            }
        }
Пример #2
0
        public async Task InitializeAsync(CancellationToken cancel)
        {
            try
            {
                InitializingChanged?.Invoke(null, true);

                if (!Synchronizer.IsRunning)
                {
                    throw new NotSupportedException($"{nameof(Synchronizer)} is not running.");
                }

                while (!BitcoinStore.IsInitialized)
                {
                    await Task.Delay(100).ConfigureAwait(false);

                    cancel.ThrowIfCancellationRequested();
                }

                await RuntimeParams.LoadAsync();

                using (await HandleFiltersLock.LockAsync())
                {
                    await LoadWalletStateAsync(cancel);
                    await LoadDummyMempoolAsync();
                }
            }
            finally
            {
                InitializingChanged?.Invoke(null, false);
            }
        }
Пример #3
0
        private async void IndexDownloader_ReorgedAsync(object sender, FilterModel invalidFilter)
        {
            try
            {
                using (await HandleFiltersLock.LockAsync())
                {
                    uint256 invalidBlockHash = invalidFilter.Header.BlockHash;
                    await DeleteBlockAsync(invalidBlockHash);

                    KeyManager.SetMaxBestHeight(new Height(invalidFilter.Header.Height - 1));
                    TransactionProcessor.UndoBlock((int)invalidFilter.Header.Height);
                    BitcoinStore.TransactionStore.ReleaseToMempoolFromBlock(invalidBlockHash);
                }
            }
            catch (Exception ex)
            {
                Logger.LogWarning(ex);
            }
        }