public BlockStorage() { m_arrStorage = new BlockStorageArray(); m_rleStorage = new BlockStorageRLE(); m_currStorage = m_arrStorage; m_isCompressed = false; }
public override void Initialize() { this._player = (IPlayer) this.Game.Services.GetService(typeof (IPlayer)); this._world = (IWorld) this.Game.Services.GetService(typeof (IWorld)); this._chunkCache = (IChunkCache) this.Game.Services.GetService(typeof (IChunkCache)); this._blockStorage = (IBlockStorage) this.Game.Services.GetService(typeof (IBlockStorage)); }
public override void Initialize() { this._player = (IPlayer)this.Game.Services.GetService(typeof(IPlayer)); this._world = (IWorld)this.Game.Services.GetService(typeof(IWorld)); this._chunkCache = (IChunkCache)this.Game.Services.GetService(typeof(IChunkCache)); this._blockStorage = (IBlockStorage)this.Game.Services.GetService(typeof(IBlockStorage)); }
/// <summary> /// Generate the given set of blockdata at the given location offset /// </summary> /// <param name="location">The xyz to use as an offset for generating these blocks</param> /// <param name="blockData">The block data to populate</param> public void generateAllAt(Coordinate location, IBlockStorage blockData) { isoSurfaceLevel = getIsoSurfaceLevel(); Coordinate.Zero.until(blockData.bounds, (coordinate) => { Coordinate globalLocation = coordinate + (location * blockData.bounds); float isoSurfaceDensityValue = getNoiseValueAt(globalLocation); blockData.updateBlock(coordinate, getBlockTypeFor(isoSurfaceDensityValue), isoSurfaceDensityValue); }); }
public RecordStorage(IBlockStorage storage) { _storage = storage ?? throw new ArgumentNullException("storage"); if (storage.BlockHeaderSize < 48) { throw new ArgumentException("Record storage needs at least 48 header bytes"); } }
// // Constructors // public RecordStorage (IBlockStorage storage) { if (storage == null) throw new ArgumentNullException ("storage"); this.storage = storage; if (storage.BlockHeaderSize < 48) { throw new ArgumentException ("Record storage needs at least 48 header bytes"); } }
// Deserialize constructor public BlockCollection(IBlockStorage <T> storage, BinaryReader reader) { _storage = storage; for (int i = 0; i < _blocksWithDepths.Length; ++i) { int count = _blocksWithDepths[i] = reader.ReadInt32(); if (count < 0 || count > storage.Count) { throw new IOException(); } } }
/// <summary> /// Generate the given set of blockdata at the given location offset /// </summary> /// <param name="location">The xyz to use as an offset for generating these blocks</param> /// <param name="blockData">The block data to populate</param> public void generateAllAt(Coordinate location, IBlockStorage blockData) { isoSurfaceLevel = getIsoSurfaceLevel(); Coordinate.Zero.until(blockData.bounds, (coordinate) => { BlocksGenerated++; Coordinate globalLocation = coordinate + (location * blockData.bounds); float isoSurfaceDensityValue = getNoiseValueAt(globalLocation); Block.Type newBlockType = getBlockTypeFor(isoSurfaceDensityValue); if (newBlockType != Block.Types.Air) { blockData.setBlock(coordinate, newBlockType); } }); }
public ExtendibleHashSet(string dataFilePath, IBlockSerializer <T> valueSerializer, int maxBlockValues, int maxSiblingMergeBlockValues, int maxTableDepth, int maxUnusedTableDepth) { if (maxBlockValues <= 0 || maxSiblingMergeBlockValues < 0 || maxTableDepth <= 0 || maxUnusedTableDepth < 0) { throw new InvalidOperationException(); } if (maxSiblingMergeBlockValues > maxBlockValues) { throw new InvalidOperationException(); } // Create index stream now just to lock file. _indexFileStream = new FileStream ( dataFilePath + IndexFilePostfix, FileMode.Create, FileAccess.ReadWrite, FileShare.None ); _blockFileStream = new FileStream ( dataFilePath + BlockFilePostfix, FileMode.Create, FileAccess.ReadWrite, FileShare.None ); _blockStorage = new StreamBlockStorage <T>( _blockFileStream, valueSerializer, UpdateIndices, blocksCount: 0, maxBlockValues: maxBlockValues); _tableContext = new TableData <T> ( new BlockCollection <T>(_blockStorage), maxBlockValues: maxBlockValues, maxSiblingMergeBlockValues: maxSiblingMergeBlockValues, maxDepth: maxTableDepth, maxUnusedDepth: maxUnusedTableDepth ); }
public void Dispose() { if (!isDisposed && isOpened) { Flush(); } isDisposed = true; DirectoryCache?.Dispose(); storage.Dispose(); DirectoryCache = null; allocationManager = null; storage = null; }
public RecordStorage(IBlockStorage blockStorage) { if (blockStorage == null) { throw new ArgumentNullException("blockStorage"); } if (blockStorage.BlockHeaderSize < BlockFields.TotalHeaderSize) { throw new ArgumentException(string.Format( "RecordStorage requires at least {0} bytes for header size.", BlockFields.TotalHeaderSize )); } this.blockStorage = blockStorage; }
public Block(IBlockStorage storage, uint id, byte[] firstSector, Stream stream) { if (firstSector == null) { throw new ArgumentNullException(nameof(firstSector)); } if (firstSector.Length != storage.DiskSectorSize) { throw new ArgumentException("firstSector length must be " + storage.DiskSectorSize); } _storage = storage; Id = id; _stream = stream ?? throw new ArgumentNullException(nameof(stream)); _firstSector = firstSector; }
private void InitializeFromHeader(IBlockStorage blockStorage, FSHeader header) { var allocationIndexFactory = new GenericFactory <IIndex <int>, IAllocationManager>( m => { var accessParameters = new CommonAccessParameters(blockStorage, m); var allocationIndexProvider = indexBlockProviderFactory.Create(header.AllocationBlock, accessParameters); return(indexFactory.Create(allocationIndexProvider, accessParameters)); }); allocationManager = allocationManagerFactory.Create(allocationIndexFactory, blockStorage, header.FreeBlockCount); var dictionaryCache = directoryCacheFactory.Create(new CommonAccessParameters(blockStorage, allocationManager)); var rootDirectory = dictionaryCache.ReadDirectory(header.RootDirectoryBlock); RootDirectory = rootDirectory; DirectoryCache = dictionaryCache; }
public Blockchain(Wallet miningWallet, IWalletManager walletManager, IHashFactory transactionHashFactory, ISignatureFactory signatureFactory, IMiningFactory miningFactory, IBlockStorage storage) { SignatureFactory = signatureFactory; Verifier = signatureFactory.GetSignatureVerifier(); MiningFactory = miningFactory; TransactionHashFactory = transactionHashFactory; Digest = TransactionHashFactory.GetDigest(); MiningWallet = miningWallet; WalletManager = walletManager; pendingTransactions = new LinkedList <Transaction>(); storedChain = storage; foreach (Block block in storedChain) { WalletManager.AcceptTransactions(block.Transactions); } }
public override void Initialize() { Logger.Trace("init()"); this.FlyingEnabled = true; this.Weapon = new Shovel(Game); // import required services. this._camera = (ICamera)this.Game.Services.GetService(typeof(ICamera)); this._chunkCache = (IChunkCache)this.Game.Services.GetService(typeof(IChunkCache)); this._blockStorage = (IBlockStorage)this.Game.Services.GetService(typeof(IBlockStorage)); this._assetManager = (IAssetManager)this.Game.Services.GetService(typeof(IAssetManager)); if (this._assetManager == null) { throw new NullReferenceException("Can not find asset manager component."); } this.LoadContent(); this.Weapon.Initialize(); }
public CoreStorage(IStorageManager storageManager, Logger logger) { for (var i = 0; i < this.presentBlockTxesLocks.Length; i++) { presentBlockTxesLocks[i] = new object(); } this.logger = logger; this.storageManager = storageManager; this.blockStorage = storageManager.BlockStorage; this.blockTxesStorage = storageManager.BlockTxesStorage; this.cachedHeaders = new ConcurrentDictionary <UInt256, ChainedHeader>(); this.missingHeaders = new ConcurrentSetBuilder <UInt256>(); this.missingBlockTxes = new ConcurrentSetBuilder <UInt256>(); foreach (var chainedHeader in this.blockStorage.ReadChainedHeaders()) { this.cachedHeaders[chainedHeader.Hash] = chainedHeader; } }
public AllocationManager( IFactory <IIndex <int>, IAllocationManager> indexFactory, IFactory <IBlockStream <int>, IBlockProvider <int> > blockStreamFactory, IBlockStorage storage, int freeSpaceBlocksCount) { if (indexFactory == null) { throw new ArgumentNullException(nameof(indexFactory)); } if (blockStreamFactory == null) { throw new ArgumentNullException(nameof(blockStreamFactory)); } this.storage = storage ?? throw new ArgumentNullException(nameof(storage)); index = indexFactory.Create(this); blockStream = blockStreamFactory.Create(index); ReleasedBlockCount = freeSpaceBlocksCount; }
public void Open(string fileName, OpenMode openMode) { if (fileName == null) { throw new ArgumentNullException(nameof(fileName)); } if (isOpened) { throw new InvalidOperationException("File system is already opened"); } storage = blockStorageFactory.Create(fileName); storage.Open(openMode); try { FSHeader header; if (openMode == OpenMode.Create) { header = CreateFile(); } else { var headers = new FSHeader[1]; storage.ReadBlock(0, headers); header = headers[0]; } InitializeFromHeader(storage, header); } catch { storage.Dispose(); } isOpened = true; }
public EmptyBlock(IBlockStorage storage, BlockPos pos) { this.storage = storage; this.position = pos; }
public PutBlockRequestHandler(IBlockStorage blockStorage) { _blockStorage = blockStorage; }
public CommonAccessParameters(IBlockStorage storage, IAllocationManager allocationManager) { Storage = storage ?? throw new ArgumentNullException(nameof(storage)); AllocationManager = allocationManager ?? throw new ArgumentNullException(nameof(allocationManager)); }
/// <summary> /// Nacitanie dat o tabulkach a indexe zo suborov /// Deserializacny konstruktor /// </summary> /// <param name="dataFilePath"></param> /// <param name="valueSerializer"></param> public ExtendibleHashSet( string dataFilePath, IBlockSerializer <T> valueSerializer) { _indexFileStream = new FileStream ( dataFilePath + IndexFilePostfix, FileMode.Open, FileAccess.ReadWrite, FileShare.None ); _blockFileStream = new FileStream ( dataFilePath + BlockFilePostfix, FileMode.Open, FileAccess.ReadWrite, FileShare.None ); var indexReader = new BinaryReader(_indexFileStream); // Table context int maxBucketValues = indexReader.ReadInt32(); int maxSiblingMergeBucketValues = indexReader.ReadInt32(); int maxTableDepth = indexReader.ReadInt32(); int maxUnusedTableDepth = indexReader.ReadInt32(); if (maxBucketValues <= 0 || maxSiblingMergeBucketValues < 0 || maxTableDepth <= 0 || maxUnusedTableDepth < 0) { throw new IOException(); } if (maxSiblingMergeBucketValues > maxBucketValues) { throw new IOException(); } // Block storage info int blocksCount = indexReader.ReadInt32(); if (blocksCount < 0) { throw new IOException(); } _blockStorage = new StreamBlockStorage <T>( _blockFileStream, valueSerializer, UpdateIndices, blocksCount: blocksCount, maxBlockValues: maxBucketValues); // Block collection var blockCollection = new BlockCollection <T>(_blockStorage, indexReader); // Tables _tableContext = new TableData <T> ( blockCollection, maxBlockValues: maxBucketValues, maxSiblingMergeBlockValues: maxSiblingMergeBucketValues, maxDepth: maxTableDepth, maxUnusedDepth: maxUnusedTableDepth ); int tablesCount = indexReader.ReadInt32(); if (tablesCount < 0) { throw new IOException(); } if (tablesCount == 0 ? blocksCount > 0 : blocksCount == 0) { throw new IOException(); } for (int i = 0; i < tablesCount; ++i) { _tables.Add(new Table <T>(indexReader, _tableContext, blocksCount)); } }
public override void Initialize() { // import required services. this._chunkCache = (IChunkCache)this.Game.Services.GetService(typeof(IChunkCache)); this._blockStorage = (IBlockStorage)this.Game.Services.GetService(typeof(IBlockStorage)); }
public BlockCollection(IBlockStorage <T> storage) { _storage = storage; }
/// <summary> /// Generate all the blocks in the given collection with this source /// </summary> /// <param name="blockData"></param> public void generateAll(IBlockStorage blockData) { generateAllAt(Coordinate.Zero, blockData); }
public RecordStorage(IBlockStorage blockStorage) { _blockStorage = blockStorage ?? throw new ArgumentNullException(nameof(blockStorage)); }
public override void Initialize() { // import required services. this._chunkCache = (IChunkCache) this.Game.Services.GetService(typeof (IChunkCache)); this._blockStorage = (IBlockStorage)this.Game.Services.GetService(typeof(IBlockStorage)); }
public BlockStream(IBlockStorage storage, StorageDirection storageDirection) { this.storage = storage; this.storageDirection = storageDirection; }
/// <summary> /// Make a chunk out of block data /// </summary> /// <param name="blocks">the block data of this chunk</param> /// <param name="neighbors">the other chunks to link to</param> public Chunk(IBlockStorage blocks, IBlockChunk[] neighbors = null) { this.blocks = blocks; this.neighbors = neighbors; }
public ChunkSection(IBlockPalette globalPalette) { BlockStorage = new BlockStorage(globalPalette); }
public override void Initialize() { Logger.Trace("init()"); this.FlyingEnabled = true; this.Weapon = new Shovel(Game); // import required services. this._camera = (ICamera) this.Game.Services.GetService(typeof (ICamera)); this._chunkCache = (IChunkCache) this.Game.Services.GetService(typeof (IChunkCache)); this._blockStorage = (IBlockStorage) this.Game.Services.GetService(typeof (IBlockStorage)); this._assetManager = (IAssetManager)this.Game.Services.GetService(typeof(IAssetManager)); if (this._assetManager == null) throw new NullReferenceException("Can not find asset manager component."); this.LoadContent(); this.Weapon.Initialize(); }