public BlockStoreSignaled( IBlockStoreQueue blockStoreQueue, StoreSettings storeSettings, IChainState chainState, IConnectionManager connection, INodeLifetime nodeLifetime, ILoggerFactory loggerFactory, IInitialBlockDownloadState initialBlockDownloadState, ISignals signals, IAsyncProvider asyncProvider) { this.blockStoreQueue = blockStoreQueue; this.chainState = chainState; this.connection = connection; this.nodeLifetime = nodeLifetime; this.logger = loggerFactory.CreateLogger(GetType().FullName); this.storeSettings = storeSettings; this.initialBlockDownloadState = initialBlockDownloadState; this.signals = signals; this.asyncProvider = asyncProvider; this.blocksToAnnounce = asyncProvider.CreateAsyncQueue <ChainedHeader>(); this.dequeueLoopTask = DequeueContinuouslyAsync(); this.asyncProvider.RegisterTask($"{nameof(BlockStoreSignaled)}.{nameof(this.dequeueLoopTask)}", this.dequeueLoopTask); }
/// <summary> /// Initializes the instance of the object and subscribes to the peer's message producer. /// </summary> /// <param name="peer">Connected network peer that we receive messages from.</param> public NetworkPeerListener(INetworkPeer peer, IAsyncProvider asyncProvider) { this.peer = peer; this.asyncProvider = asyncProvider; this.asyncIncomingMessagesQueue = asyncProvider.CreateAsyncQueue <IncomingMessage>(); this.messageProducerRegistration = peer.MessageProducer.AddMessageListener(this); }
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); }