示例#1
0
        public void PreProcess(Block block, ProcessingOptions options = ProcessingOptions.None)
        {
            bool isProducingBlock    = options.IsProducingBlock();
            long previousBlockNumber = block.Number - 1;
            bool isNotConsecutive    = previousBlockNumber != _lastProcessedBlock;

            if (isProducingBlock || isNotConsecutive)
            {
                if (TryGetLastValidator(previousBlockNumber, out var validatorInfo))
                {
                    if (validatorInfo.Value.ValidatorType.CanChangeImmediately())
                    {
                        SetCurrentValidator(validatorInfo);
                    }
                    else if (!isProducingBlock)
                    {
                        bool canSetValidatorAsCurrent = !TryGetLastValidator(validatorInfo.Key - 1, out var previousValidatorInfo);
                        long?finalizedAtBlockNumber   = null;
                        if (!canSetValidatorAsCurrent)
                        {
                            SetCurrentValidator(previousValidatorInfo);
                            finalizedAtBlockNumber   = _blockFinalizationManager.GetFinalizedLevel(validatorInfo.Key);
                            canSetValidatorAsCurrent = finalizedAtBlockNumber != null;
                        }

                        if (canSetValidatorAsCurrent)
                        {
                            SetCurrentValidator(finalizedAtBlockNumber ?? validatorInfo.Key, validatorInfo.Value);
                        }
                    }
                }
            }

            _currentValidator?.PreProcess(block, options);
        }
示例#2
0
 public void PreProcess(Block block)
 {
     if (_logger.IsInfo)
     {
         if (TryGetValidator(block.Header.Number, out var validator))
         {
             _logger.Info($"Signal for switch to chainspec {validator.ValidatorType} based validator set at block {block.Number}.");
         }
     }
     _currentValidator?.PreProcess(block);
 }
示例#3
0
 public void PreProcess(Block block)
 {
     if (TryUpdateValidator(block))
     {
         if (_logger.IsInfo)
         {
             _logger.Info($"Signal for switch to {_currentValidator.Type} based validator set at block {block.Number}.");
         }
     }
     _currentValidator?.PreProcess(block);
 }
示例#4
0
        public void PreProcess(Block block, ProcessingOptions options = ProcessingOptions.None)
        {
            bool isProducingBlock = options.IsProducingBlock();

            if (isProducingBlock && TryGetLastValidator(block.Number - 1, out var validatorInfo))
            {
                AuRaParameters.Validator validator = validatorInfo?.Value;
                if (CanChangeImmediately(validator.ValidatorType))
                {
                    SetCurrentValidator(block.Number, validator);
                }
            }

            _currentValidator?.PreProcess(block, options);
        }