Exemplo n.º 1
0
        public uint GetLength(OmniHash hash)
        {
            // Cache
            {
                uint length = _blockStorage.GetLength(hash);
                if (length != 0)
                {
                    return(length);
                }
            }

            // Share
            {
                lock (_lockObject)
                {
                    var sharedBlocksInfo = _contentMetadataStorage.GetSharedBlocksInfo(hash);

                    if (sharedBlocksInfo != null)
                    {
                        return((uint)Math.Min(sharedBlocksInfo.Length - ((ulong)sharedBlocksInfo.BlockLength * (uint)sharedBlocksInfo.GetIndex(hash)), sharedBlocksInfo.BlockLength));
                    }
                }
            }

            return(0);
        }