public BlockStoreCache(
            IBlockRepository blockRepository,
            IDateTimeProvider dateTimeProvider,
            ILoggerFactory loggerFactory,
            StoreSettings storeSettings)
        {
            Guard.NotNull(blockRepository, nameof(blockRepository));

            this.cache              = new MemoryCache <uint256, Block>(storeSettings.MaxCacheBlocksCount);
            this.blockRepository    = blockRepository;
            this.dateTimeProvider   = dateTimeProvider;
            this.PerformanceCounter = this.BlockStoreCachePerformanceCounterFactory();
            this.logger             = loggerFactory.CreateLogger(this.GetType().FullName);
        }
Ejemplo n.º 2
0
 public ProvenHeadersBlockStoreSignaled(
     Network network,
     IBlockStoreQueue blockStoreQueue,
     StoreSettings storeSettings,
     IChainState chainState,
     IConnectionManager connection,
     INodeLifetime nodeLifetime,
     ILoggerFactory loggerFactory,
     IInitialBlockDownloadState initialBlockDownloadState,
     IProvenBlockHeaderStore provenBlockHeaderStore)
     : base(blockStoreQueue, storeSettings, chainState, connection, nodeLifetime, loggerFactory, initialBlockDownloadState)
 {
     this.network = Guard.NotNull(network, nameof(network));
     this.provenBlockHeaderStore = Guard.NotNull(provenBlockHeaderStore, nameof(provenBlockHeaderStore));
 }
Ejemplo n.º 3
0
        public BlockStoreSignaled(
            IBlockStoreQueue blockStoreQueue,
            StoreSettings storeSettings,
            IChainState chainState,
            IConnectionManager connection,
            INodeLifetime nodeLifetime,
            ILoggerFactory loggerFactory,
            IInitialBlockDownloadState initialBlockDownloadState)
        {
            this.blockStoreQueue           = blockStoreQueue;
            this.chainState                = chainState;
            this.connection                = connection;
            this.nodeLifetime              = nodeLifetime;
            this.logger                    = loggerFactory.CreateLogger(this.GetType().FullName);
            this.storeSettings             = storeSettings;
            this.initialBlockDownloadState = initialBlockDownloadState;

            this.blocksToAnnounce = new AsyncQueue <ChainedHeader>();
            this.dequeueLoopTask  = this.DequeueContinuouslyAsync();
        }
Ejemplo n.º 4
0
        public BlockStoreSignaled(
            BlockStoreLoop blockStoreLoop,
            ConcurrentChain chain,
            StoreSettings storeSettings,
            IChainState chainState,
            IConnectionManager connection,
            INodeLifetime nodeLifetime,
            ILoggerFactory loggerFactory,
            IBlockStoreCache blockStoreCache)
        {
            this.blockStoreLoop  = blockStoreLoop;
            this.chain           = chain;
            this.chainState      = chainState;
            this.connection      = connection;
            this.nodeLifetime    = nodeLifetime;
            this.logger          = loggerFactory.CreateLogger(this.GetType().FullName);
            this.storeSettings   = storeSettings;
            this.blockStoreCache = blockStoreCache;

            this.blocksToAnnounce = new AsyncQueue <ChainedHeader>();
            this.dequeueLoopTask  = this.DequeueContinuouslyAsync();
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
        public BlockStoreFeature(
            ConcurrentChain chain,
            IConnectionManager connectionManager,
            Signals.Signals signals,
            BlockStoreSignaled blockStoreSignaled,
            ILoggerFactory loggerFactory,
            StoreSettings storeSettings,
            IChainState chainState,
            IBlockStoreQueue blockStoreQueue,
            INodeStats nodeStats)
        {
            this.chain              = chain;
            this.blockStoreQueue    = blockStoreQueue;
            this.signals            = signals;
            this.blockStoreSignaled = blockStoreSignaled;
            this.connectionManager  = connectionManager;
            this.logger             = loggerFactory.CreateLogger(this.GetType().FullName);
            this.loggerFactory      = loggerFactory;
            this.storeSettings      = storeSettings;
            this.chainState         = chainState;

            nodeStats.RegisterStats(this.AddInlineStats, StatsType.Inline, 900);
        }
        private readonly ConcurrentDictionary <uint256, uint256> blockHashesToAnnounce; // maybe replace with a task scheduler

        public BlockStoreSignaled(
            BlockStoreLoop blockStoreLoop,
            ConcurrentChain chain,
            StoreSettings storeSettings,
            ChainState chainState,
            IConnectionManager connection,
            INodeLifetime nodeLifetime,
            IAsyncLoopFactory asyncLoopFactory,
            IBlockRepository blockRepository,
            ILoggerFactory loggerFactory,
            string name = "BlockStore")
        {
            this.asyncLoopFactory      = asyncLoopFactory;
            this.blockHashesToAnnounce = new ConcurrentDictionary <uint256, uint256>();
            this.blockRepository       = blockRepository;
            this.blockStoreLoop        = blockStoreLoop;
            this.chain         = chain;
            this.chainState    = chainState;
            this.connection    = connection;
            this.name          = name;
            this.nodeLifetime  = nodeLifetime;
            this.logger        = loggerFactory.CreateLogger(GetType().FullName);
            this.storeSettings = storeSettings;
        }
Ejemplo n.º 8
0
        public BlockStoreQueue(
            IBlockRepository blockRepository,
            ConcurrentChain chain,
            IChainState chainState,
            StoreSettings storeSettings,
            INodeLifetime nodeLifetime,
            ILoggerFactory loggerFactory)
        {
            Guard.NotNull(blockRepository, nameof(blockRepository));
            Guard.NotNull(chain, nameof(chain));
            Guard.NotNull(chainState, nameof(chainState));
            Guard.NotNull(storeSettings, nameof(storeSettings));
            Guard.NotNull(nodeLifetime, nameof(nodeLifetime));
            Guard.NotNull(loggerFactory, nameof(loggerFactory));

            this.chainState      = chainState;
            this.nodeLifetime    = nodeLifetime;
            this.storeSettings   = storeSettings;
            this.chain           = chain;
            this.blockRepository = blockRepository;

            this.blocksQueue = new AsyncQueue <BlockPair>();
            this.logger      = loggerFactory.CreateLogger(this.GetType().FullName);
        }
Ejemplo n.º 9
0
 public BlockStoreSignaled(
     BlockStoreLoop blockStoreLoop,
     ConcurrentChain chain,
     StoreSettings storeSettings,
     ChainState chainState,
     IConnectionManager connection,
     INodeLifetime nodeLifetime,
     IAsyncLoopFactory asyncLoopFactory,
     ILoggerFactory loggerFactory,
     IBlockStoreCache blockStoreCache,
     string name = "BlockStore")
 {
     this.asyncLoopFactory = asyncLoopFactory;
     this.blocksToAnnounce = new ConcurrentQueue <ChainedBlock>();
     this.blockStoreLoop   = blockStoreLoop;
     this.chain            = chain;
     this.chainState       = chainState;
     this.connection       = connection;
     this.name             = name;
     this.nodeLifetime     = nodeLifetime;
     this.logger           = loggerFactory.CreateLogger(this.GetType().FullName);
     this.storeSettings    = storeSettings;
     this.blockStoreCache  = blockStoreCache;
 }
 /// <summary>
 /// Get the default configuration.
 /// </summary>
 /// <param name="builder">The string builder to add the settings to.</param>
 /// <param name="network">The network to base the defaults off.</param>
 public static void BuildDefaultConfigurationFile(StringBuilder builder, Network network)
 {
     StoreSettings.BuildDefaultConfigurationFile(builder, network);
 }
 /// <summary>
 /// Prints command-line help.
 /// </summary>
 /// <param name="network">The network to extract values from.</param>
 public static void PrintHelp(Network network)
 {
     StoreSettings.PrintHelp();
 }