コード例 #1
0
        public CoinviewTests()
        {
            this.network          = new StraxMain();
            this.dataFolder       = TestBase.CreateDataFolder(this);
            this.dateTimeProvider = new DateTimeProvider();
            this.loggerFactory    = new ExtendedLoggerFactory();
            this.nodeStats        = new NodeStats(this.dateTimeProvider, this.loggerFactory);

            this.coindb = new DBreezeCoindb(this.network, this.dataFolder, this.dateTimeProvider, this.loggerFactory, this.nodeStats, new DBreezeSerializer(this.network.Consensus.ConsensusFactory));
            this.coindb.Initialize();

            this.chainIndexer    = new ChainIndexer(this.network);
            this.stakeChainStore = new StakeChainStore(this.network, this.chainIndexer, (IStakedb)this.coindb, this.loggerFactory);
            this.stakeChainStore.Load();

            this.rewindDataIndexCache = new RewindDataIndexCache(this.dateTimeProvider, this.network, new FinalizedBlockInfoRepository(new HashHeightPair()), new Checkpoints());

            this.cachedCoinView = new CachedCoinView(this.network, new Checkpoints(), this.coindb, this.dateTimeProvider, this.loggerFactory, this.nodeStats, new ConsensusSettings(new NodeSettings(this.network)), this.stakeChainStore, this.rewindDataIndexCache);

            this.rewindDataIndexCache.Initialize(this.chainIndexer.Height, this.cachedCoinView);

            this.random = new Random();

            ChainedHeader newTip = ChainedHeadersHelper.CreateConsecutiveHeaders(1000, this.chainIndexer.Tip, true, null, this.network).Last();

            this.chainIndexer.SetTip(newTip);
        }
コード例 #2
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);
            }
        }