public ProvenBlockHeaderStore(
            IDateTimeProvider dateTimeProvider,
            ILoggerFactory loggerFactory,
            IProvenBlockHeaderRepository provenBlockHeaderRepository,
            INodeStats nodeStats,
            IInitialBlockDownloadState initialBlockDownloadState)
        {
            Guard.NotNull(loggerFactory, nameof(loggerFactory));
            Guard.NotNull(provenBlockHeaderRepository, nameof(provenBlockHeaderRepository));
            Guard.NotNull(nodeStats, nameof(nodeStats));

            this.logger = loggerFactory.CreateLogger(this.GetType().FullName);
            this.provenBlockHeaderRepository = provenBlockHeaderRepository;
            this.initialBlockDownloadState   = initialBlockDownloadState;

            this.lockObject   = new object();
            this.pendingBatch = new SortedDictionary <int, ProvenBlockHeader>();
            this.Cache        = new MemorySizeCache <int, ProvenBlockHeader>(this.MemoryCacheSizeLimitInBytes);

            this.performanceCounter = new BackendPerformanceCounter(dateTimeProvider);

            if (nodeStats.DisplayBenchStats)
            {
                nodeStats.RegisterStats(this.AddBenchStats, StatsType.Benchmark, this.GetType().Name);
            }

            nodeStats.RegisterStats(this.AddComponentStats, StatsType.Component, this.GetType().Name);
        }
        /// <summary>
        /// Initializes a new instance of the object.
        /// </summary>
        /// <param name="dateTimeProvider">Provider of time functions.</param>
        /// <param name="loggerFactory">Factory to create a logger for this type.</param>
        /// <param name="provenBlockHeaderRepository">Persistent interface of the <see cref="ProvenBlockHeader"/> DBreeze repository.</param>
        /// <param name="nodeLifetime">Allows consumers to perform clean-up during a graceful shutdown.</param>
        /// <param name="nodeStats">Registers an action used to append node stats when collected.</param>
        /// <param name="asyncLoopFactory">Factory for creating and also possibly starting application defined tasks inside async loop.</param>
        public ProvenBlockHeaderStore(
            IDateTimeProvider dateTimeProvider,
            ILoggerFactory loggerFactory,
            IProvenBlockHeaderRepository provenBlockHeaderRepository,
            INodeLifetime nodeLifetime,
            INodeStats nodeStats,
            IAsyncLoopFactory asyncLoopFactory)
        {
            Guard.NotNull(loggerFactory, nameof(loggerFactory));
            Guard.NotNull(provenBlockHeaderRepository, nameof(provenBlockHeaderRepository));
            Guard.NotNull(nodeLifetime, nameof(nodeLifetime));
            Guard.NotNull(nodeStats, nameof(nodeStats));
            Guard.NotNull(asyncLoopFactory, nameof(asyncLoopFactory));

            this.logger = loggerFactory.CreateLogger(this.GetType().FullName);
            this.provenBlockHeaderRepository = provenBlockHeaderRepository;
            this.nodeLifetime = nodeLifetime;

            this.lockObject   = new object();
            this.PendingBatch = new Dictionary <int, ProvenBlockHeader>();
            this.Cache        = new MemorySizeCache <int, ProvenBlockHeader>(this.MemoryCacheSizeLimitInBytes);

            this.asyncLoopFactory = asyncLoopFactory;

            this.performanceCounter = new BackendPerformanceCounter(dateTimeProvider);
            nodeStats.RegisterStats(this.AddBenchStats, StatsType.Benchmark);
            nodeStats.RegisterStats(this.AddComponentStats, StatsType.Component);
        }
        public RewindDataIndexStore(IDateTimeProvider dateTimeProvider)
        {
            Guard.NotNull(dateTimeProvider, nameof(dateTimeProvider));

            this.items = new ConcurrentDictionary <string, int>();

            this.performanceCounter = new BackendPerformanceCounter(dateTimeProvider);
        }
        public RewindDataIndexCache(IDateTimeProvider dateTimeProvider, Network network)
        {
            Guard.NotNull(dateTimeProvider, nameof(dateTimeProvider));

            this.network = network;

            this.items = new ConcurrentDictionary <OutPoint, int>();

            this.performanceCounter = new BackendPerformanceCounter(dateTimeProvider);
        }
示例#5
0
        public RewindDataIndexCache(IDateTimeProvider dateTimeProvider, Network network, IFinalizedBlockInfoRepository finalizedBlockInfoRepository, ICheckpoints checkpoints)
        {
            Guard.NotNull(dateTimeProvider, nameof(dateTimeProvider));

            this.network = network;
            this.finalizedBlockInfoRepository = finalizedBlockInfoRepository;
            this.checkpoints    = checkpoints;
            this.items          = new ConcurrentDictionary <OutPoint, int>();
            this.lastCheckpoint = this.checkpoints.LastCheckpointHeight;

            this.performanceCounter = new BackendPerformanceCounter(dateTimeProvider);
        }
示例#6
0
        public FasterCoindb(Network network, string folder, IDateTimeProvider dateTimeProvider, ILoggerFactory loggerFactory, INodeStats nodeStats, DataStoreSerializer dataStoreSerializer)
        {
            Guard.NotNull(network, nameof(network));
            Guard.NotEmpty(folder, nameof(folder));

            this.dataStoreSerializer = dataStoreSerializer;

            // Create the coinview folder if it does not exist.
            Directory.CreateDirectory(folder);

            this.logger             = loggerFactory.CreateLogger(this.GetType().FullName);
            this.network            = network;
            this.performanceCounter = new BackendPerformanceCounter(dateTimeProvider);
            this.dataFolder         = folder;

            nodeStats.RegisterStats(this.AddBenchStats, StatsType.Benchmark, this.GetType().Name, 400);
        }
示例#7
0
        public RocksDbCoindb(Network network, string folder, IDateTimeProvider dateTimeProvider,
                             ILoggerFactory loggerFactory, INodeStats nodeStats, DataStoreSerializer dataStoreSerializer)
        {
            Guard.NotNull(network, nameof(network));
            Guard.NotEmpty(folder, nameof(folder));

            this.dataStoreSerializer = dataStoreSerializer;

            this.logger = loggerFactory.CreateLogger(this.GetType().FullName);

            // Open a connection to a new DB and create if not found
            var options = new DbOptions().SetCreateIfMissing(true);

            this.rocksdb = RocksDb.Open(options, folder);

            this.network            = network;
            this.performanceCounter = new BackendPerformanceCounter(dateTimeProvider);

            nodeStats.RegisterStats(this.AddBenchStats, StatsType.Benchmark, this.GetType().Name, 400);
        }
 public BackendPerformanceCounterTest()
 {
     this.performanceCounter = new BackendPerformanceCounter(DateTimeProvider.Default);
 }