Ejemplo n.º 1
0
        public async Task <int> ReIndexAsync()
        {
            var last = await _Index.GetAsync <DiskBlockPos>(IndexedLimit).ConfigureAwait(false);

            int count = 0;
            List <TStoredItem> lastBlocks = null;

            foreach (var blocks in EnumerateForIndex(new DiskBlockPosRange(last)).Partition(400))
            {
                count += blocks.Count;
                await _Index.PutBatch(blocks.Select(b => new Tuple <String, IBitcoinSerializable>(GetKey(b.Item), b.BlockPosition))).ConfigureAwait(false);

                lastBlocks = blocks;
            }
            if (lastBlocks != null && lastBlocks.Count > 0)
            {
                var block = lastBlocks.Last();
                await _Index.PutAsync(IndexedLimit, new DiskBlockPos(block.BlockPosition.File, block.BlockPosition.Position + (uint)block.GetStorageSize())).ConfigureAwait(false);
            }
            return(count);
        }