private async Task Initialise()
        {
            if (_progress != null)
            {
                return;
            }

            _progress = await LoadAsync().ConfigureAwait(false);

            if (_progress == null)
            {
                _progress = new BlockProcessingProgress {
                    To = _initialBlockNumber
                };
                await PersistAsync().ConfigureAwait(false);
            }
            else
            {
                if (_initialBlockNumber != null) // we've been given a starting point
                {
                    if (_progress.To == null || _progress.To < _initialBlockNumber)
                    {
                        await UpsertProgressAsync(_initialBlockNumber.Value).ConfigureAwait(false);
                    }
                }
            }
        }
示例#2
0
 private void CreateAndPersist()
 {
     _progress = new BlockProcessingProgress();
     Persist();
 }
示例#3
0
        private void Load()
        {
            var json = File.ReadAllText(JsonFileNameAndPath);

            _progress = JsonConvert.DeserializeObject <BlockProcessingProgress>(json);
        }