Beispiel #1
0
        private async Task RunBlockTreeInitTasks()
        {
            if (!_initConfig.SynchronizationEnabled)
            {
                return;
            }

            if (!_syncConfig.FastSync)
            {
                await _blockTree.LoadBlocksFromDb(_runnerCancellation.Token, null).ContinueWith(t =>
                {
                    if (t.IsFaulted)
                    {
                        if (_logger.IsError)
                        {
                            _logger.Error("Loading blocks from the DB failed.", t.Exception);
                        }
                    }
                    else if (t.IsCanceled)
                    {
                        if (_logger.IsWarn)
                        {
                            _logger.Warn("Loading blocks from the DB canceled.");
                        }
                    }
                });
            }
            else
            {
                await _blockTree.FixFastSyncGaps(_runnerCancellation.Token).ContinueWith(t =>
                {
                    if (t.IsFaulted)
                    {
                        if (_logger.IsError)
                        {
                            _logger.Error("Fixing gaps in DB failed.", t.Exception);
                        }
                    }
                    else if (t.IsCanceled)
                    {
                        if (_logger.IsWarn)
                        {
                            _logger.Warn("Fixing gaps in DB canceled.");
                        }
                    }
                });
            }
        }
Beispiel #2
0
 public async Task FixFastSyncGaps(CancellationToken cancellationToken)
 {
     await _blockTree.FixFastSyncGaps(cancellationToken);
 }