/// <summary> /// Releases given <see cref="BlockChain"/>. /// </summary> /// <param name="chain">Released chain.</param> private void releaseChain(BlockChain chain) { chain.Block = null; chain.Next = null; chain.DataSize = 0; chain.DataOffset = 0; _freeChains.Push(chain); }
/// <summary> /// Chains given block. /// </summary> /// <param name="block">Block to chain.</param> /// <param name="previousChain">Previous chain, where created chain will be appended.</param> /// <returns>Chain with given block.</returns> private BlockChain chainBlock(Block block, int dataOffset, int dataSize, BlockChain previousChain = null) { BlockChain freeChain; if (_freeChains.Count == 0) freeChain = new BlockChain(); else freeChain = _freeChains.Pop(); freeChain.Block = block; freeChain.DataOffset = dataOffset; freeChain.DataSize = dataSize; if (previousChain != null) //chain with previous chain if available previousChain.Next = freeChain; return freeChain; }