Example #1
0
        /// <summary>
        /// Simply write all packs, no journal is required.
        /// </summary>
        public void Write(ShortCoinPackCollection coll)
        {
            for (var i = 0; i < coll.Count; ++i)
            {
                var pack = coll[i];

                Debug.Assert(pack.LayerIndex <= _layers.Length);
                if (pack.LayerIndex == _layers.Length)
                {
                    _bottomLayer.Set(pack.SectorIndex, pack.Span);
                }
                else
                {
                    pack.Span.CopyTo(ReadSpan(pack.LayerIndex, pack.SectorIndex));
                }
            }
        }
Example #2
0
        private void WriteSector(uint sectorIndex, Span <byte> s0, Span <byte> s1, Span <byte> s2, Span <byte> s3)
        {
            var p0 = new CoinPack(s0)
            {
                LayerIndex  = 0, SectorIndex = sectorIndex, Version = CoinPack.CurrentVersion,
                SizeInBytes = _fixture.SectorsSize[0]
            };
            var p1 = new CoinPack(s1)
            {
                LayerIndex  = 1, SectorIndex = sectorIndex, Version = CoinPack.CurrentVersion,
                SizeInBytes = _fixture.SectorsSize[1]
            };
            var p2 = new CoinPack(s2)
            {
                LayerIndex  = 2, SectorIndex = sectorIndex, Version = CoinPack.CurrentVersion,
                SizeInBytes = _fixture.SectorsSize[2]
            };

            var collection = new ShortCoinPackCollection(p0);

            collection.Add(p1);
            collection.Add(p2);

            if (!s3.IsEmpty)
            {
                var p3 = new CoinPack(s3)
                {
                    LayerIndex  = 3, SectorIndex = sectorIndex, Version = CoinPack.CurrentVersion,
                    SizeInBytes = s3.Length
                };
                collection.Add(p3);
            }

            try
            {
                _fixture.CreateStore();
                _fixture.Store.Write(collection);
            }
            finally
            {
                _fixture.CloseStore();
            }
        }