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); } } } }
private void CreateAndPersist() { _progress = new BlockProcessingProgress(); Persist(); }
private void Load() { var json = File.ReadAllText(JsonFileNameAndPath); _progress = JsonConvert.DeserializeObject <BlockProcessingProgress>(json); }