Beispiel #1
0
        public void ValidateQueueAvailabilityBeforeDownload_Test()
        {
            _blockDownloadService.ValidateQueueAvailabilityBeforeDownload().ShouldBeTrue();

            _blockSyncStateProvider.SetEnqueueTime(OSConstants.BlockSyncAttachQueueName,
                                                   TimestampHelper.GetUtcNow()
                                                   .AddMilliseconds(-BlockSyncConstants.BlockSyncAttachBlockAgeLimit - 1000));
            _blockDownloadService.ValidateQueueAvailabilityBeforeDownload().ShouldBeFalse();

            _blockSyncStateProvider.SetEnqueueTime(KernelConstants.UpdateChainQueueName,
                                                   TimestampHelper.GetUtcNow()
                                                   .AddMilliseconds(-BlockSyncConstants.BlockSyncAttachAndExecuteBlockAgeLimit - 1000));
            _blockDownloadService.ValidateQueueAvailabilityBeforeDownload().ShouldBeFalse();
        }
Beispiel #2
0
        private bool ValidateBeforeDownload(BlockDownloadJobInfo blockDownloadJobInfo)
        {
            if (blockDownloadJobInfo == null)
            {
                return(false);
            }

            if (!_blockDownloadService.ValidateQueueAvailabilityBeforeDownload())
            {
                return(false);
            }

            if (blockDownloadJobInfo.CurrentTargetBlockHash != null &&
                _blockDownloadService.IsNotReachedDownloadTarget(blockDownloadJobInfo.CurrentTargetBlockHash) &&
                TimestampHelper.GetUtcNow() < blockDownloadJobInfo.Deadline)
            {
                return(false);
            }

            return(true);
        }