/// <summary>
        ///
        /// </summary>
        /// <param name="blockTree"></param>
        /// <param name="blockProcessor"></param>
        /// <param name="recoveryStep"></param>
        /// <param name="logManager"></param>
        /// <param name="options"></param>
        public BlockchainProcessor(
            IBlockTree blockTree,
            IBlockProcessor blockProcessor,
            IBlockDataRecoveryStep recoveryStep,
            ILogManager logManager,
            Options options)
        {
            _logger         = logManager?.GetClassLogger() ?? throw new ArgumentNullException(nameof(logManager));
            _blockTree      = blockTree ?? throw new ArgumentNullException(nameof(blockTree));
            _blockProcessor = blockProcessor ?? throw new ArgumentNullException(nameof(blockProcessor));
            _recoveryStep   = recoveryStep ?? throw new ArgumentNullException(nameof(recoveryStep));
            _options        = options;

            if (_options.AutoProcess)
            {
                _blockTree.NewBestSuggestedBlock += OnNewBestBlock;
            }

            _stats = new ProcessingStats(_logger);
        }
Example #2
0
        private const int MaxProcessingQueueSize = 2000;  // adjust based on tx or gas

        /// <summary>
        ///
        /// </summary>
        /// <param name="blockTree"></param>
        /// <param name="blockProcessor"></param>
        /// <param name="recoveryStep"></param>
        /// <param name="logManager"></param>
        /// <param name="storeReceiptsByDefault"></param>
        /// <param name="autoProcess">Registers for OnNewHeadBlock events at block tree.</param>
        public BlockchainProcessor(
            IBlockTree blockTree,
            IBlockProcessor blockProcessor,
            IBlockDataRecoveryStep recoveryStep,
            ILogManager logManager,
            bool storeReceiptsByDefault,
            bool autoProcess = true)
        {
            _logger                 = logManager?.GetClassLogger() ?? throw new ArgumentNullException(nameof(logManager));
            _blockTree              = blockTree ?? throw new ArgumentNullException(nameof(blockTree));
            _blockProcessor         = blockProcessor ?? throw new ArgumentNullException(nameof(blockProcessor));
            _recoveryStep           = recoveryStep ?? throw new ArgumentNullException(nameof(recoveryStep));
            _storeReceiptsByDefault = storeReceiptsByDefault;

            if (autoProcess)
            {
                _blockTree.NewBestSuggestedBlock += OnNewBestBlock;
            }

            _stats = new ProcessingStats(_logger);
        }