コード例 #1
0
        public TestContext()
        {
            var chain = new ConcurrentChain(this.Network);
            var extendedLoggerFactory   = new ExtendedLoggerFactory();
            var dateTimeProvider        = new DateTimeProvider();
            var hashStore               = new InvalidBlockHashStore(dateTimeProvider);
            var powConsensusRulesEngine = new PowConsensusRuleEngine(this.Network, extendedLoggerFactory, dateTimeProvider, chain,
                                                                     new NodeDeployments(this.Network, chain), this.ConsensusSettings, this.Checkpoints.Object, new Mock <ICoinView>().Object,
                                                                     this.ChainState.Object, hashStore, new NodeStats(dateTimeProvider));

            this.PartialValidation = new PartialValidator(powConsensusRulesEngine, extendedLoggerFactory);
            this.FullValidation    = new FullValidator(powConsensusRulesEngine, extendedLoggerFactory);
            this.HeaderValidator   = new Mock <IHeaderValidator>();
            this.HeaderValidator.Setup(hv => hv.ValidateHeader(It.IsAny <ChainedHeader>())).Returns(new ValidationContext());

            this.ChainedHeaderTree = new ChainedHeaderTree(
                this.Network,
                extendedLoggerFactory,
                this.HeaderValidator.Object,
                this.Checkpoints.Object,
                this.ChainState.Object,
                this.FinalizedBlockMock.Object,
                this.ConsensusSettings,
                hashStore);

            this.ConsensusManager = CreateConsensusManager();
        }
コード例 #2
0
ファイル: BaseFeature.cs プロジェクト: FluidChains/FullNode
        public BaseFeature(NodeSettings nodeSettings,
                           DataFolder dataFolder,
                           INodeLifetime nodeLifetime,
                           ChainIndexer chainIndexer,
                           IChainState chainState,
                           IConnectionManager connectionManager,
                           IChainRepository chainRepository,
                           IFinalizedBlockInfoRepository finalizedBlockInfo,
                           IDateTimeProvider dateTimeProvider,
                           IAsyncProvider asyncProvider,
                           ITimeSyncBehaviorState timeSyncBehaviorState,
                           ILoggerFactory loggerFactory,
                           IInitialBlockDownloadState initialBlockDownloadState,
                           IPeerBanning peerBanning,
                           IPeerAddressManager peerAddressManager,
                           IConsensusManager consensusManager,
                           IConsensusRuleEngine consensusRules,
                           IPartialValidator partialValidator,
                           IBlockPuller blockPuller,
                           IBlockStore blockStore,
                           Network network,
                           ITipsManager tipsManager,
                           NodeDeployments nodeDeployments,
                           IKeyValueRepository keyValueRepo,
                           INodeStats nodeStats,
                           IBroadcasterManager broadcasterManager,
                           IProvenBlockHeaderStore provenBlockHeaderStore = null)
        {
            this.chainState      = Guard.NotNull(chainState, nameof(chainState));
            this.chainRepository = Guard.NotNull(chainRepository, nameof(chainRepository));
            this.finalizedBlockInfoRepository = Guard.NotNull(finalizedBlockInfo, nameof(finalizedBlockInfo));
            this.nodeSettings           = Guard.NotNull(nodeSettings, nameof(nodeSettings));
            this.dataFolder             = Guard.NotNull(dataFolder, nameof(dataFolder));
            this.nodeLifetime           = Guard.NotNull(nodeLifetime, nameof(nodeLifetime));
            this.chainIndexer           = Guard.NotNull(chainIndexer, nameof(chainIndexer));
            this.connectionManager      = Guard.NotNull(connectionManager, nameof(connectionManager));
            this.consensusManager       = consensusManager;
            this.consensusRules         = consensusRules;
            this.blockPuller            = blockPuller;
            this.blockStore             = blockStore;
            this.network                = network;
            this.nodeStats              = nodeStats;
            this.broadcasterManager     = broadcasterManager;
            this.provenBlockHeaderStore = provenBlockHeaderStore;
            this.partialValidator       = partialValidator;
            this.peerBanning            = Guard.NotNull(peerBanning, nameof(peerBanning));
            this.tipsManager            = Guard.NotNull(tipsManager, nameof(tipsManager));
            this.keyValueRepo           = Guard.NotNull(keyValueRepo, nameof(keyValueRepo));
            this.nodeDeployments        = nodeDeployments;

            this.peerAddressManager = Guard.NotNull(peerAddressManager, nameof(peerAddressManager));
            this.peerAddressManager.PeerFilePath = this.dataFolder;

            this.initialBlockDownloadState = initialBlockDownloadState;
            this.dateTimeProvider          = dateTimeProvider;
            this.asyncProvider             = asyncProvider;
            this.timeSyncBehaviorState     = timeSyncBehaviorState;
            this.loggerFactory             = loggerFactory;
            this.logger = loggerFactory.CreateLogger(this.GetType().FullName);
        }
コード例 #3
0
        public BaseFeature(
            NodeSettings nodeSettings,
            DataFolder dataFolder,
            INodeLifetime nodeLifetime,
            ConcurrentChain chain,
            IChainState chainState,
            IConnectionManager connectionManager,
            IChainRepository chainRepository,
            IFinalizedBlockInfoRepository finalizedBlockInfo,
            IDateTimeProvider dateTimeProvider,
            IAsyncLoopFactory asyncLoopFactory,
            ITimeSyncBehaviorState timeSyncBehaviorState,
            DBreezeSerializer dbreezeSerializer,
            ILoggerFactory loggerFactory,
            IInitialBlockDownloadState initialBlockDownloadState,
            IPeerBanning peerBanning,
            IPeerAddressManager peerAddressManager,
            IConsensusManager consensusManager,
            IConsensusRuleEngine consensusRules,
            IPartialValidator partialValidator,
            IBlockPuller blockPuller,
            IBlockStore blockStore,
            Network network)
        {
            this.chainState      = Guard.NotNull(chainState, nameof(chainState));
            this.chainRepository = Guard.NotNull(chainRepository, nameof(chainRepository));
            this.finalizedBlockInfoRepository = Guard.NotNull(finalizedBlockInfo, nameof(finalizedBlockInfo));
            this.nodeSettings      = Guard.NotNull(nodeSettings, nameof(nodeSettings));
            this.dataFolder        = Guard.NotNull(dataFolder, nameof(dataFolder));
            this.nodeLifetime      = Guard.NotNull(nodeLifetime, nameof(nodeLifetime));
            this.chain             = Guard.NotNull(chain, nameof(chain));
            this.connectionManager = Guard.NotNull(connectionManager, nameof(connectionManager));
            this.consensusManager  = consensusManager;
            this.consensusRules    = consensusRules;
            this.blockPuller       = blockPuller;
            this.blockStore        = blockStore;
            this.network           = network;
            this.partialValidator  = partialValidator;
            this.peerBanning       = Guard.NotNull(peerBanning, nameof(peerBanning));

            this.peerAddressManager = Guard.NotNull(peerAddressManager, nameof(peerAddressManager));
            this.peerAddressManager.PeerFilePath = this.dataFolder;

            this.initialBlockDownloadState = initialBlockDownloadState;
            this.dateTimeProvider          = dateTimeProvider;
            this.asyncLoopFactory          = asyncLoopFactory;
            this.timeSyncBehaviorState     = timeSyncBehaviorState;
            this.loggerFactory             = loggerFactory;
            this.dbreezeSerializer         = dbreezeSerializer;
            this.logger = loggerFactory.CreateLogger(this.GetType().FullName);
        }