Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
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);
        }