public async Task <FilterModel> RemoveLastFilterAsync(CancellationToken cancel) { FilterModel?filter = null; using (await IndexLock.LockAsync(cancel).ConfigureAwait(false)) { filter = ImmatureFilters.Last(); ImmatureFilters.RemoveLast(); if (SmartHeaderChain.TipHeight != filter.Header.Height) { throw new InvalidOperationException($"{nameof(SmartHeaderChain)} and {nameof(ImmatureFilters)} are not in sync."); } SmartHeaderChain.RemoveTip(); } Reorged?.Invoke(this, filter); AbandonedTasks.AddAndClearCompleted(TryCommitToFileAsync(TimeSpan.FromSeconds(3), cancel)); return(filter); }
public async Task <FilterModel> RemoveLastFilterAsync(CancellationToken cancel) { FilterModel filter = null; using (await IndexLock.LockAsync()) { filter = ImmatureFilters.Last(); ImmatureFilters.RemoveLast(); if (HashChain.TipHeight != filter.BlockHeight.Value) { throw new InvalidOperationException("HashChain and ImmatureFilters are not in sync."); } HashChain.RemoveLast(); } Reorged?.Invoke(this, filter); _ = TryCommitToFileAsync(TimeSpan.FromSeconds(3), cancel); return(filter); }