public ExtendedBlockPullerBehavior(IBlockPuller blockPuller, IInitialBlockDownloadState ibdState, ILoggerFactory loggerFactory)
 {
     this.ShouldThrowAtRequestBlocksAsync  = false;
     this.RecalculateQualityScoreWasCalled = false;
     this.RequestedHashes    = new List <uint256>();
     this.underlyingBehavior = new BlockPullerBehavior(blockPuller, ibdState, loggerFactory);
 }
Example #2
0
        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);
        }
Example #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);
        }
Example #4
0
        public ConsensusManager(
            Network network,
            ILoggerFactory loggerFactory,
            IChainState chainState,
            IHeaderValidator headerValidator,
            IIntegrityValidator integrityValidator,
            IPartialValidation partialValidation,
            ICheckpoints checkpoints,
            ConsensusSettings consensusSettings,
            IConsensusRules consensusRules,
            IFinalizedBlockHeight finalizedBlockHeight,
            Signals.Signals signals,
            IPeerBanning peerBanning,
            NodeSettings nodeSettings,
            IDateTimeProvider dateTimeProvider,
            IInitialBlockDownloadState ibdState,
            ConcurrentChain chain,
            IBlockStore blockStore = null)
        {
            this.network              = network;
            this.chainState           = chainState;
            this.partialValidation    = partialValidation;
            this.consensusSettings    = consensusSettings;
            this.consensusRules       = consensusRules;
            this.signals              = signals;
            this.peerBanning          = peerBanning;
            this.blockStore           = blockStore;
            this.finalizedBlockHeight = finalizedBlockHeight;
            this.chain  = chain;
            this.logger = loggerFactory.CreateLogger(this.GetType().FullName);

            this.chainedHeaderTree = new ChainedHeaderTree(network, loggerFactory, headerValidator, integrityValidator, checkpoints, chainState, finalizedBlockHeight, consensusSettings, signals);

            this.peerLock               = new object();
            this.reorgLock              = new AsyncLock();
            this.blockRequestedLock     = new object();
            this.expectedBlockDataBytes = 0;
            this.expectedBlockSizes     = new Dictionary <uint256, long>();

            this.callbacksByBlocksRequestedHash = new Dictionary <uint256, List <OnBlockDownloadedCallback> >();
            this.peersByPeerId   = new Dictionary <int, INetworkPeer>();
            this.toDownloadQueue = new Queue <BlockDownloadRequest>();
            this.ibdState        = ibdState;

            ProtocolVersion protocolVersion = nodeSettings.ProtocolVersion;

            this.blockPuller = new BlockPuller(this.BlockDownloaded, this.chainState, protocolVersion, dateTimeProvider, loggerFactory);
        }
Example #5
0
        public BlockPullerBehavior(IBlockPuller blockPuller, IInitialBlockDownloadState ibdState, IDateTimeProvider dateTimeProvider, ILoggerFactory loggerFactory)
        {
            this.ibdState         = ibdState;
            this.dateTimeProvider = dateTimeProvider;
            this.QualityScore     = SamplelessQualityScore;

            this.averageSizeBytes    = new AverageCalculator(IbdSamplesCount);
            this.averageDelaySeconds = new AverageCalculator(IbdSamplesCount);
            this.SpeedBytesPerSecond = 0;
            this.lastDeliveryTime    = null;

            this.blockPuller = blockPuller;

            this.logger        = loggerFactory.CreateLogger(this.GetType().FullName);
            this.loggerFactory = loggerFactory;
        }
        public BlockPullerBehavior(IBlockPuller blockPuller, IInitialBlockDownloadState ibdState, ILoggerFactory loggerFactory)
        {
            this.ibdState     = ibdState;
            this.QualityScore = SamplelessQualityScore;

            int samplesCount = ibdState.IsInitialBlockDownload() ? IbdSamplesCount : NormalSamplesCount;

            this.averageSizeBytes    = new AverageCalculator(samplesCount);
            this.averageDelaySeconds = new AverageCalculator(samplesCount);
            this.SpeedBytesPerSecond = 0;

            this.blockPuller = blockPuller;

            this.logger        = loggerFactory.CreateLogger(this.GetType().FullName, $"[{this.GetHashCode():x}] ");
            this.loggerFactory = loggerFactory;
        }