private async void IndexDownloader_NewFilterAsync(object sender, FilterModel filterModel) { using (HandleFiltersLock.Lock()) using (WalletBlocksLock.Lock()) { if (filterModel.Filter != null && !WalletBlocks.ContainsValue(filterModel.BlockHash)) { await ProcessFilterModelAsync(filterModel, CancellationToken.None); } } NewFilterProcessed?.Invoke(this, filterModel); }
public async Task InitializeAsync(CancellationToken cancel) { if (!IndexDownloader.IsRunning) { throw new NotSupportedException($"{nameof(IndexDownloader)} is not running."); } using (HandleFiltersLock.Lock()) using (WalletBlocksLock.Lock()) { // Go through the filters and que to download the matches. var filters = IndexDownloader.GetFiltersIncluding(IndexDownloader.StartingFilter.BlockHeight); foreach (var filterModel in filters.Where(x => x.Filter != null && !WalletBlocks.ContainsValue(x.BlockHash))) // Filter can be null if there is no bech32 tx. { await ProcessFilterModelAsync(filterModel, cancel); } } }
private async void IndexDownloader_ReorgedAsync(object sender, uint256 invalidBlockHash) { using (HandleFiltersLock.Lock()) using (WalletBlocksLock.Lock()) { var elem = WalletBlocks.SingleOrDefault(x => x.Value == invalidBlockHash); await DeleteBlockAsync(invalidBlockHash); WalletBlocks.RemoveByValue(invalidBlockHash); ProcessedBlocks.Remove(invalidBlockHash); if (elem.Key != null) { foreach (var toRemove in Coins.Where(x => x.Height == elem.Key).ToHashSet()) { RemoveCoinRecursively(toRemove); } } } }