public BlockStoreQueue(
            ConcurrentChain chain,
            IChainState chainState,
            IBlockStoreQueueFlushCondition blockStoreQueueFlushCondition,
            StoreSettings storeSettings,
            IBlockRepository blockRepository,
            ILoggerFactory loggerFactory,
            INodeStats nodeStats)
        {
            Guard.NotNull(blockStoreQueueFlushCondition, nameof(blockStoreQueueFlushCondition));
            Guard.NotNull(chain, nameof(chain));
            Guard.NotNull(chainState, nameof(chainState));
            Guard.NotNull(storeSettings, nameof(storeSettings));
            Guard.NotNull(loggerFactory, nameof(loggerFactory));

            this.blockStoreQueueFlushCondition = blockStoreQueueFlushCondition;
            this.chain              = chain;
            this.chainState         = chainState;
            this.storeSettings      = storeSettings;
            this.blockRepository    = blockRepository;
            this.batch              = new List <ChainedHeaderBlock>();
            this.blocksCacheLock    = new object();
            this.blocksQueue        = new AsyncQueue <ChainedHeaderBlock>();
            this.pendingBlocksCache = new Dictionary <uint256, ChainedHeaderBlock>();
            this.logger             = loggerFactory.CreateLogger(this.GetType().FullName);
            this.cancellation       = new CancellationTokenSource();

            this.BatchThresholdSizeBytes = storeSettings.MaxCacheSize * 1024 * 1024;

            nodeStats.RegisterStats(this.AddComponentStats, StatsType.Component);
        }
Example #2
0
        public BlockStoreQueue(
            ChainIndexer chainIndexer,
            IChainState chainState,
            IBlockStoreQueueFlushCondition blockStoreQueueFlushCondition,
            StoreSettings storeSettings,
            IBlockRepository blockRepository,
            ILoggerFactory loggerFactory,
            INodeStats nodeStats,
            IAsyncProvider asyncProvider,
            IInitialBlockDownloadState initialBlockDownloadState)
        {
            Guard.NotNull(blockStoreQueueFlushCondition, nameof(blockStoreQueueFlushCondition));
            Guard.NotNull(chainIndexer, nameof(chainIndexer));
            Guard.NotNull(chainState, nameof(chainState));
            Guard.NotNull(storeSettings, nameof(storeSettings));
            Guard.NotNull(loggerFactory, nameof(loggerFactory));
            Guard.NotNull(blockRepository, nameof(blockRepository));
            Guard.NotNull(nodeStats, nameof(nodeStats));

            this.initialBlockDownloadState     = initialBlockDownloadState;
            this.blockStoreQueueFlushCondition = blockStoreQueueFlushCondition;
            this.chainIndexer           = chainIndexer;
            this.chainState             = chainState;
            this.storeSettings          = storeSettings;
            this.blockRepository        = blockRepository;
            this.asyncProvider          = asyncProvider;
            this.batch                  = new List <ChainedHeaderBlock>();
            this.blocksCacheLock        = new object();
            this.blocksQueue            = asyncProvider.CreateAsyncQueue <ChainedHeaderBlock>();
            this.pendingBlocksCache     = new Dictionary <uint256, ChainedHeaderBlock>();
            this.logger                 = loggerFactory.CreateLogger(this.GetType().FullName);
            this.cancellation           = new CancellationTokenSource();
            this.saveAsyncLoopException = null;

            this.BatchThresholdSizeBytes = storeSettings.MaxCacheSize * 1024 * 1024;

            nodeStats.RegisterStats(this.AddComponentStats, StatsType.Component, this.GetType().Name);
        }