예제 #1
0
        public async ValueTask LoadAsync()
        {
            using (await _settingsAsyncLock.LockAsync())
            {
                if (_loaded)
                {
                    throw new SettingsAlreadyLoadedException();
                }

                _loaded = true;

                await _blockStorage.LoadAsync();

                if (_settings.TryGetContent <ContentStorageConfig>("Config", out var config))
                {
                    foreach (var contentInfo in config.ContentMetadatas)
                    {
                        _contentMetadataStorage.Add(contentInfo);

                        foreach (var hash in contentInfo.LockedHashes)
                        {
                            _blockStorage.Lock(hash);
                        }
                    }
                }

                _checkEventScheduler.ChangeInterval(new TimeSpan(0, 10, 0));
                await _checkEventScheduler.RestartAsync();
            }
        }
예제 #2
0
        public async ValueTask LoadAsync()
        {
            using (await _settingsAsyncLock.LockAsync())
            {
                if (_loaded)
                {
                    throw new SettingsAlreadyLoadedException();
                }

                _loaded = true;

                _size = 0;
                _clusterMetadataMap.Clear();

                if (_settings.TryGetContent <BlockStorageConfig>("config", out var config))
                {
                    _size = config.Size;

                    foreach (var(key, value) in config.ClusterMetadataMap)
                    {
                        _clusterMetadataMap.Add(key, value);
                    }
                }

                this.UpdateUsingSectors();
            }
        }