예제 #1
0
        public CachedCoinView(Network network, ICheckpoints checkpoints, ICoindb coindb, IDateTimeProvider dateTimeProvider, ILoggerFactory loggerFactory, INodeStats nodeStats, ConsensusSettings consensusSettings, StakeChainStore stakeChainStore = null, IRewindDataIndexCache rewindDataIndexCache = null)
        {
            Guard.NotNull(coindb, nameof(CachedCoinView.coindb));

            this.coindb               = coindb;
            this.logger               = loggerFactory.CreateLogger(this.GetType().FullName);
            this.network              = network;
            this.checkpoints          = checkpoints;
            this.dateTimeProvider     = dateTimeProvider;
            this.consensusSettings    = consensusSettings;
            this.stakeChainStore      = stakeChainStore;
            this.rewindDataIndexCache = rewindDataIndexCache;
            this.lockobj              = new object();
            this.cachedUtxoItems      = new Dictionary <OutPoint, CacheItem>();
            this.performanceCounter   = new CachePerformanceCounter(this.dateTimeProvider);
            this.lastCacheFlushTime   = this.dateTimeProvider.GetUtcNow();
            this.cachedRewindData     = new Dictionary <int, RewindData>();
            this.random               = new Random();

            this.lastCheckpointHeight = this.checkpoints.GetLastCheckpointHeight();

            this.MaxCacheSizeBytes             = consensusSettings.MaxCoindbCacheInMB * 1024 * 1024;
            this.CacheFlushTimeIntervalSeconds = consensusSettings.CoindbIbdFlushMin * 60;

            if (nodeStats.DisplayBenchStats)
            {
                nodeStats.RegisterStats(this.AddBenchStats, StatsType.Benchmark, this.GetType().Name, 300);
            }
        }
        /// <summary>
        /// Initializes instance of the object based.
        /// </summary>
        /// <param name="dateTimeProvider">Provider of time functions.</param>
        /// <param name="loggerFactory">Factory to be used to create logger for the puller.</param>
        /// <param name="stakeChainStore">Storage of POS block information.</param>
        private CachedCoinView(IDateTimeProvider dateTimeProvider, ILoggerFactory loggerFactory, INodeStats nodeStats, StakeChainStore stakeChainStore = null)
        {
            this.logger               = loggerFactory.CreateLogger(this.GetType().FullName);
            this.dateTimeProvider     = dateTimeProvider;
            this.stakeChainStore      = stakeChainStore;
            this.MaxItems             = CacheMaxItemsDefault;
            this.lockobj              = new AsyncLock();
            this.cachedUtxoItems      = new Dictionary <uint256, CacheItem>();
            this.performanceCounter   = new CachePerformanceCounter(this.dateTimeProvider);
            this.lastCacheFlushTime   = this.dateTimeProvider.GetUtcNow();
            this.cachedRewindDataList = new List <RewindData>();

            nodeStats.RegisterStats(this.AddBenchStats, StatsType.Benchmark, 300);
        }
예제 #3
0
        /// <summary>
        /// Initializes instance of the object based.
        /// </summary>
        /// <param name="dateTimeProvider">Provider of time functions.</param>
        /// <param name="loggerFactory">Factory to be used to create logger for the puller.</param>
        /// <param name="nodeStats">The node stats.</param>
        /// <param name="stakeChainStore">Storage of POS block information.</param>
        /// <param name="rewindDataIndexCache">Rewind data index store.</param>
        private CachedCoinView(IDateTimeProvider dateTimeProvider, ILoggerFactory loggerFactory, INodeStats nodeStats, StakeChainStore stakeChainStore = null, IRewindDataIndexCache rewindDataIndexCache = null)
        {
            this.logger                = loggerFactory.CreateLogger("Impleum.Bitcoin.FullNode");
            this.dateTimeProvider      = dateTimeProvider;
            this.stakeChainStore       = stakeChainStore;
            this.rewindDataIndexCache  = rewindDataIndexCache;
            this.MaxItems              = CacheMaxItemsDefault;
            this.lockobj               = new object();
            this.cachedUtxoItems       = new Dictionary <uint256, CacheItem>();
            this.performanceCounter    = new CachePerformanceCounter(this.dateTimeProvider);
            this.lastCacheFlushTime    = this.dateTimeProvider.GetUtcNow();
            this.cachedRewindDataIndex = new SortedDictionary <int, RewindData>();
            this.random                = new Random();

            nodeStats.RegisterStats(this.AddBenchStats, StatsType.Benchmark, 300);
        }