Exemple #1
0
 public void RemoveDownloadJobTargetState(Hash targetBlockHash)
 {
     if (targetBlockHash != null)
     {
         _blockSyncStateProvider.TryRemoveDownloadJobTargetState(targetBlockHash);
     }
 }
Exemple #2
0
        private async Task RunWorkerAsync(int times, List <BlockWithTransactions> peerBlocks)
        {
            for (int i = 0; i < times; i++)
            {
                foreach (var block in peerBlocks)
                {
                    _blockSyncStateProvider.TryRemoveDownloadJobTargetState(block.GetHash());
                }

                await _blockDownloadWorker.ProcessDownloadJobAsync();
            }
        }
        public void DownloadJobTargetState_Test()
        {
            var targetHash = HashHelper.ComputeFrom("TargetHash");
            var result     = _blockSyncStateProvider.TryUpdateDownloadJobTargetState(targetHash, false);

            result.ShouldBeFalse();

            _blockSyncStateProvider.SetDownloadJobTargetState(targetHash, false);
            result = _blockSyncStateProvider.TryGetDownloadJobTargetState(targetHash, out var value);
            result.ShouldBeTrue();
            value.ShouldBeFalse();

            result = _blockSyncStateProvider.TryUpdateDownloadJobTargetState(targetHash, false);
            result.ShouldBeFalse();

            result = _blockSyncStateProvider.TryUpdateDownloadJobTargetState(targetHash, true);
            result.ShouldBeTrue();

            _blockSyncStateProvider.TryRemoveDownloadJobTargetState(targetHash);
            result = _blockSyncStateProvider.TryGetDownloadJobTargetState(targetHash, out value);
            result.ShouldBeFalse();
        }