Esempio n. 1
0
 public StakeChainStore(Network network, ConcurrentChain chain, DBreezeCoinView dBreezeCoinView, ILoggerFactory loggerFactory)
 {
     this.logger            = loggerFactory.CreateLogger(this.GetType().FullName);
     this.network           = network;
     this.chain             = chain;
     this.dBreezeCoinView   = dBreezeCoinView;
     this.threshold         = 5000;                                  // Count of items in memory.
     this.thresholdWindow   = Convert.ToInt32(this.threshold * 0.4); // A window threshold.
     this.genesis           = BlockStake.Load(this.network.GetGenesis());
     this.genesis.HashProof = this.network.GenesisHash;
     this.genesis.Flags     = BlockFlag.BLOCK_STAKE_MODIFIER;
 }
        public NodeContext(string name, Network network)
        {
            network   = network ?? Network.TestNet;
            this.name = name;
            if (Clean)
            {
                CleanDirectory();
            }
            _Network = network;

            _PersistentCoinView = new DBreezeCoinView(network, name);
            _PersistentCoinView.Initialize();
            _CleanList.Add(_PersistentCoinView);
        }
Esempio n. 3
0
        public ConsensusFeature(
            IAsyncLoopFactory asyncLoopFactory,
            DBreezeCoinView dBreezeCoinView,
            Network network,
            PowConsensusValidator consensusValidator,
            ConcurrentChain chain,
            LookaheadBlockPuller blockPuller,
            CoinView coinView,
            ChainState chainState,
            IConnectionManager connectionManager,
            INodeLifetime nodeLifetime,
            Signals.Signals signals,
            ConsensusLoop consensusLoop,
            NodeSettings nodeSettings,
            NodeDeployments nodeDeployments,
            ILoggerFactory loggerFactory,
            IDateTimeProvider dateTimeProvider,
            ConsensusManager consensusManager,
            ConsensusStats consensusStats,
            ConsensusSettings consensusSettings,
            IRuleRegistration ruleRegistration,
            IConsensusRules consensusRules,
            StakeChainStore stakeChain = null)
        {
            this.dBreezeCoinView    = dBreezeCoinView;
            this.consensusValidator = consensusValidator;
            this.chain             = chain;
            this.blockPuller       = blockPuller;
            this.coinView          = coinView;
            this.chainState        = chainState;
            this.connectionManager = connectionManager;
            this.nodeLifetime      = nodeLifetime;
            this.signals           = signals;
            this.network           = network;
            this.consensusLoop     = consensusLoop;
            this.nodeSettings      = nodeSettings;
            this.nodeDeployments   = nodeDeployments;
            this.stakeChain        = stakeChain;
            this.logger            = loggerFactory.CreateLogger(this.GetType().FullName);
            this.loggerFactory     = loggerFactory;
            this.dateTimeProvider  = dateTimeProvider;
            this.consensusManager  = consensusManager;
            this.consensusStats    = consensusStats;
            this.consensusSettings = consensusSettings;
            this.ruleRegistration  = ruleRegistration;
            this.consensusRules    = consensusRules;

            this.chainState.MaxReorgLength = this.network.Consensus.Option <PowConsensusOptions>().MaxReorgLength;
        }
            public ConsensusStats(FullNode fullNode, CoinViewStack stack)
            {
                this.fullNode = fullNode;

                stack   = new CoinViewStack(fullNode.CoinView);
                cache   = stack.Find <CachedCoinView>();
                dbreeze = stack.Find <DBreezeCoinView>();
                bottom  = stack.Bottom;

                lookaheadPuller = fullNode.ConsensusLoop.Puller as LookaheadBlockPuller;

                lastSnapshot  = fullNode.ConsensusLoop.Validator.PerformanceCounter.Snapshot();
                lastSnapshot2 = dbreeze?.PerformanceCounter.Snapshot();
                lastSnapshot3 = cache?.PerformanceCounter.Snapshot();
            }
Esempio n. 5
0
        public static IFullNodeBuilder AddRequired(this IFullNodeBuilder builder)
        {
            builder.UseBaseFeature();

            // TODO: move some of the required services will move to their own feature
            return(builder.ConfigureServices(service =>
            {
                var dataFolder = new DataFolder(builder.NodeSettings);

                // TODO: move to ConsensusFeature (required for mempool)
                var coinviewdb = new DBreezeCoinView(builder.Network, dataFolder.CoinViewPath);
                var coinView = new CachedCoinView(coinviewdb)
                {
                    MaxItems = builder.NodeSettings.Cache.MaxItems
                };
                var consensusValidator = new ConsensusValidator(builder.Network.Consensus);
                service.AddSingleton(consensusValidator);
                service.AddSingleton <DBreezeCoinView>(coinviewdb);
                service.AddSingleton <CoinView>(coinView);
            }));
        }
 public ConsensusFeature(
     DBreezeCoinView dBreezeCoinView,
     Network network,
     PowConsensusValidator consensusValidator,
     ConcurrentChain chain,
     LookaheadBlockPuller blockPuller,
     CoinView coinView,
     ChainState chainState,
     IConnectionManager connectionManager,
     INodeLifetime nodeLifetime,
     Signals.Signals signals,
     ConsensusLoop consensusLoop,
     NodeSettings nodeSettings,
     NodeDeployments nodeDeployments,
     ILoggerFactory loggerFactory,
     IDateTimeProvider dateTimeProvider,
     ConsensusManager consensusManager,
     StakeChainStore stakeChain = null)
 {
     this.dBreezeCoinView    = dBreezeCoinView;
     this.consensusValidator = consensusValidator;
     this.chain             = chain;
     this.blockPuller       = blockPuller;
     this.coinView          = coinView;
     this.chainState        = chainState;
     this.connectionManager = connectionManager;
     this.nodeLifetime      = nodeLifetime;
     this.signals           = signals;
     this.network           = network;
     this.consensusLoop     = consensusLoop;
     this.nodeSettings      = nodeSettings;
     this.nodeDeployments   = nodeDeployments;
     this.stakeChain        = stakeChain;
     this.logger            = loggerFactory.CreateLogger(this.GetType().FullName);
     this.loggerFactory     = loggerFactory;
     this.dateTimeProvider  = dateTimeProvider;
     this.consensusManager  = consensusManager;
 }
        public ConsensusFeature(
            DBreezeCoinView dBreezeCoinView,
            Network network,
            LookaheadBlockPuller blockPuller,
            CoinView coinView,
            IChainState chainState,
            IConnectionManager connectionManager,
            Signals.Signals signals,
            IConsensusLoop consensusLoop,
            NodeDeployments nodeDeployments,
            ILoggerFactory loggerFactory,
            ConsensusStats consensusStats,
            IRuleRegistration ruleRegistration,
            IConsensusRules consensusRules,
            NodeSettings nodeSettings,
            ConsensusSettings consensusSettings,
            StakeChainStore stakeChain = null)
        {
            this.dBreezeCoinView   = dBreezeCoinView;
            this.blockPuller       = blockPuller;
            this.coinView          = coinView;
            this.chainState        = chainState;
            this.connectionManager = connectionManager;
            this.signals           = signals;
            this.consensusLoop     = consensusLoop;
            this.nodeDeployments   = nodeDeployments;
            this.stakeChain        = stakeChain;
            this.logger            = loggerFactory.CreateLogger(this.GetType().FullName);
            this.loggerFactory     = loggerFactory;
            this.consensusStats    = consensusStats;
            this.ruleRegistration  = ruleRegistration;
            this.nodeSettings      = nodeSettings;
            this.consensusSettings = consensusSettings;
            this.consensusRules    = consensusRules;

            this.chainState.MaxReorgLength = network.Consensus.MaxReorgLength;
        }