internal void Add <TransactionType>(long blockId, TransactionItem <TransactionType> item) where TransactionType : Operation
        {
            var transaction   = item.Transaction;
            var transactionId = transaction.OperationId;

            var split = TransactionSliceInfo.IsSliceSplit(transactionId);

            lock (_lock)
            {
                _transactionSlice.AddEntry(transactionId, item.ToByteArray());

                _currentBlockId = blockId;
                if (_currentFirsBlockId == Protocol.InvalidBlockId)
                {
                    _currentFirsBlockId = blockId;
                }

                _transactionSlice.FirstBlockId = _currentFirsBlockId;
                _transactionSlice.LastBlockId  = _currentBlockId;
                _transactionSlice.Split        = split;
            }

            if (split)
            {
                Save();
                Split(blockId);
            }
        }
        public long GetSliceIdForTransactionId(long transactionId)
        {
            var idx = TransactionSliceInfo.GetSliceIndex(transactionId);

            if (idx < 0)
            {
                return(0);
            }

            lock (_lock)
                return(_slices.Count > 0 && _slices.Count > idx ? idx : 0);
        }
        public byte[] GetTransactionItemData(long transactionId)
        {
            var sliceIndex     = TransactionSliceInfo.GetSliceIndex(transactionId);
            var inCurrentSlice = sliceIndex == _currentSliceId;

            if (sliceIndex >= 0)
            {
                DiscStorage storage = null;

                if (!inCurrentSlice)
                {
                    TransactionSliceInfo slice = null;
                    lock (_lock)
                        slice = _slices[(int)sliceIndex];

                    lock (_lock)
                    {
                        _readonlyTransactionSlices.TryGetValue(slice.SliceId, out storage);
                    }

                    if (storage == null)
                    {
                        storage = GetTransactionStorage(slice.SliceId);

                        lock (_lock)
                        {
                            _readonlyTransactionSlices[slice.SliceId] = storage;
                        }
                    }
                }
                else
                {
                    lock (_lock)
                    {
                        storage = _transactionSlice;
                    }
                }

                if (storage != null)
                {
                    if (transactionId >= 0)
                    {
                        return(storage.GetBlockData(transactionId));
                    }
                }
            }

            return(null);
        }