BitSharp.Esent.EsentBlockTxesStorage.DeleteElements C# (CSharp) Method

DeleteElements() public method

public DeleteElements ( IEnumerable blockTxIndices ) : void
blockTxIndices IEnumerable
return void
        public void DeleteElements(IEnumerable<KeyValuePair<UInt256, IEnumerable<int>>> blockTxIndices)
        {
            using (var handle = this.cursorCache.TakeItem())
            {
                var cursor = handle.Item;

                foreach (var keyPair in blockTxIndices)
                {
                    var blockHash = keyPair.Key;
                    var txIndices = keyPair.Value;

                    using (var jetTx = cursor.jetSession.BeginTransaction())
                    {
                        int blockIndex;
                        if (!TryGetBlockIndex(cursor, blockHash, out blockIndex))
                            continue;

                        // prune the transactions
                        foreach (var index in txIndices)
                        {
                            // remove transactions
                            Api.JetSetCurrentIndex(cursor.jetSession, cursor.blocksTableId, "IX_BlockIndexTxIndex");
                            Api.MakeKey(cursor.jetSession, cursor.blocksTableId, blockIndex, MakeKeyGrbit.NewKey);
                            Api.MakeKey(cursor.jetSession, cursor.blocksTableId, index, MakeKeyGrbit.None);

                            if (Api.TrySeek(cursor.jetSession, cursor.blocksTableId, SeekGrbit.SeekEQ))
                                Api.JetDelete(cursor.jetSession, cursor.blocksTableId);
                        }

                        jetTx.CommitLazy();
                    }
                }
            }
        }