Exemplo n.º 1
0
 public MetaStorageInfo(Feature feature, string name, int blockSize, DiscStorageFlags storageFlags)
 {
     Feature      = feature;
     Name         = name;
     BlockSize    = blockSize;
     StorageFlags = storageFlags;
 }
 internal BlockHeaderInfo(BlockHeader blockHeader)
 {
     Flags             = blockHeader.Flags;
     StartIndex        = blockHeader.StartIndex;
     EndIndex          = blockHeader.EndIndex;
     Count             = blockHeader.Count;
     DynamicStartIndex = blockHeader.DynamicStartIndex;
     DynamicEndIndex   = blockHeader.DynamicEndIndex;
     UserData          = blockHeader.UserData;
     BlockSize         = blockHeader.BlockSize;
 }
            public BlockHeader(Unpacker unpacker)
            {
                unpacker.Unpack(out Version);

                unpacker.Unpack(out BlockSize);
                Flags = (DiscStorageFlags)unpacker.UnpackULong();

                unpacker.Unpack(out int userDataSize);
                UserData = new byte[userDataSize];
                unpacker.Unpack(UserData, 0, userDataSize);

                unpacker.Unpack(out StartIndex);
                unpacker.Unpack(out EndIndex);
                unpacker.Unpack(out Count);

                unpacker.Unpack(out DynamicStartIndex);
                unpacker.Unpack(out DynamicEndIndex);
            }
Exemplo n.º 4
0
        public TransactionStorage(Base.Storage storage, ChainType chainType, int chainId, uint chainIndex)
        {
            _blockSize    = 0;
            _storageFlags = DiscStorageFlags.DynamicBlockSize;
            _storage      = storage;

            ChainId    = chainId;
            ChainIndex = chainIndex;

            TransactionsPath            = GetTransactionStoragePath(chainType, chainId, chainIndex);
            FullTransactionsStoragePath = Path.Combine(storage.Root.FullName, TransactionsPath);

            CreateRequiredDirectories(storage, chainType, chainId, chainIndex);

            _currentSliceId = 0;
            _slices         = GetTransactionSlices(storage, chainType, chainId, chainIndex, false);

            // remove the last "hot" slice
            if (_slices.Count > 0)
            {
                var last = _slices.Last().Value;
                if (last.Finalized)
                {
                    _currentSliceId = last.SliceId + 1;
                }
                else
                {
                    _currentSliceId = last.SliceId;
                    _slices.RemoveAt(_slices.Count - 1);
                }
            }

            _transactionSlice = new TransactionDiscStorage(_storage, Path.Combine(TransactionsPath, _currentSliceId.ToString()), _blockSize, _storageFlags);

            _currentFirsBlockId = _transactionSlice.FirstBlockId;
            _currentBlockId     = _transactionSlice.LastBlockId;
        }
 public TransactionDiscStorage(Base.Storage storage, string name, int blockSize, DiscStorageFlags flags) : base(storage, name, blockSize, 32, flags)
 {
     if (UserDataUnpacker.UnpackBool())
     {
         UserDataUnpacker.UnpackUshort();
         FirstBlockId = UserDataUnpacker.UnpackLong();
         LastBlockId  = UserDataUnpacker.UnpackLong();
         Split        = UserDataUnpacker.UnpackBool();
     }
 }
Exemplo n.º 6
0
 public MetaDiscStorage(Base.Storage storage, ChainType chainType, int chainId, uint chainIndex, string name, int blockSize, DiscStorageFlags flags, int userDataSize = 20) : base(storage, Path.Combine(Chain.GetChainMetaDirectory(chainType, chainId, chainIndex), name), blockSize, userDataSize, flags)
 {
     if (UserDataUnpacker.UnpackBool())
     {
         LastBlockId       = UserDataUnpacker.UnpackLong();
         LastTransactionId = UserDataUnpacker.UnpackLong();
         MetaUnpack();
     }
 }
Exemplo n.º 7
0
        public IMetaStorage AddMetaStorage(Feature feature, string name, int blockSize, DiscStorageFlags storageFlags)
        {
            var info = new MetaStorageInfo(feature, name, blockSize, storageFlags);

            _storagesInfo.Add(info);
            return(info);
        }