private IAuRaValidator CreateAuRaValidator(IBlockProcessor processor)
        {
            if (_api.ChainSpec == null)
            {
                throw new StepDependencyException(nameof(_api.ChainSpec));
            }
            if (_api.BlockTree == null)
            {
                throw new StepDependencyException(nameof(_api.BlockTree));
            }
            if (_api.EngineSigner == null)
            {
                throw new StepDependencyException(nameof(_api.EngineSigner));
            }

            var chainSpecAuRa = _api.ChainSpec.AuRa;

            _api.FinalizationManager = new AuRaBlockFinalizationManager(
                _api.BlockTree,
                _api.ChainLevelInfoRepository,
                processor,
                _api.ValidatorStore,
                new ValidSealerStrategy(),
                _api.LogManager,
                chainSpecAuRa.TwoThirdsMajorityTransition);

            IAuRaValidator validator = new AuRaValidatorFactory(
                _api.StateProvider,
                _api.AbiEncoder,
                _api.TransactionProcessor,
                GetReadOnlyTransactionProcessorSource(),
                _api.BlockTree,
                _api.ReceiptStorage,
                _api.ValidatorStore,
                _api.FinalizationManager,
                new TxPoolSender(_api.TxPool, new NonceReservingTxSealer(_api.EngineSigner, _api.Timestamper, _api.TxPool)),
                _api.TxPool,
                _api.Config <IMiningConfig>(),
                _api.LogManager,
                _api.EngineSigner,
                _api.ReportingContractValidatorCache,
                chainSpecAuRa.PosdaoTransition,
                false)
                                       .CreateValidatorProcessor(chainSpecAuRa.Validators, _api.BlockTree.Head?.Header);

            if (validator is IDisposable disposableValidator)
            {
                _api.DisposeStack.Push(disposableValidator);
            }

            return(validator);
        }
Пример #2
0
        protected override void BuildProducer()
        {
            if (_api.Signer == null)
            {
                throw new StepDependencyException(nameof(_api.Signer));
            }
            if (_api.ChainSpec == null)
            {
                throw new StepDependencyException(nameof(_api.ChainSpec));
            }

            _auraConfig = _api.Config <IAuraConfig>();
            ILogger logger = _api.LogManager.GetClassLogger();

            if (logger.IsWarn)
            {
                logger.Warn("Starting AuRa block producer & sealer");
            }

            IAuRaStepCalculator  stepCalculator  = new AuRaStepCalculator(_api.ChainSpec.AuRa.StepDuration, _api.Timestamper, _api.LogManager);
            BlockProducerContext producerContext = GetProducerChain();

            _api.BlockProducer = new AuRaBlockProducer(
                producerContext.TxSource,
                producerContext.ChainProcessor,
                producerContext.ReadOnlyStateProvider,
                _api.Sealer,
                _api.BlockTree,
                _api.BlockProcessingQueue,
                _api.Timestamper,
                stepCalculator,
                _api.ReportingValidator,
                _auraConfig,
                CreateGasLimitCalculator(producerContext.ReadOnlyTxProcessorSource),
                _api.LogManager);
        }