public void OnPeriodicWorkException(IPeriodicWork failedWork, Exception ex, ref IPeriodicWorkExceptionHandler.Feedback feedback) { _logger.LogCritical("An unhandled exception has been raised in the block validation loop."); feedback.IsCritical = true; feedback.ContinueExecution = false; feedback.Message = "Without block validation loop, it's impossible to advance in consensus. A node restart is required to fix the problem."; }
public NetworkRequiredConnection(ILogger <NetworkRequiredConnection> logger, IEventBus eventBus, IOptions <LightningNodeSettings> options, IConnectivityPeerStats serverPeerStats, IForgeClientConnectivity forgeConnectivity, IPeriodicWork connectionLoop) : base(logger, eventBus, serverPeerStats, forgeConnectivity, connectionLoop) { _settings = options.Value !; }
public BitcoinConnectionManager(ILogger <ConnectionManager> logger, IEventBus eventBus, IStatisticFeedsCollector statisticFeedsCollector, IEnumerable <IConnector> connectors, IRandomNumberGenerator randomNumberGenerator, IPeriodicWork periodicPeerHealthCheck) : base(logger, eventBus, statisticFeedsCollector, connectors) { _randomNumberGenerator = randomNumberGenerator; _periodicPeerHealthCheck = periodicPeerHealthCheck; }
public PingPongProcessor(ILogger <PingPongProcessor> logger, IEventBus eventBus, IPeerBehaviorManager peerBehaviorManager, IRandomNumberGenerator randomNumberGenerator, IDateTimeProvider dateTimeProvider, IPeriodicWork periodicPing) : base(logger, eventBus, peerBehaviorManager, isHandshakeAware: true, receiveMessagesOnlyIfHandshaked: true) { _randomNumberGenerator = randomNumberGenerator; _dateTimeProvider = dateTimeProvider; _periodicPing = periodicPing; }
public void StopTracking(IPeriodicWork work) { if (work is null) { ThrowHelper.ThrowArgumentNullException(nameof(work)); } if (_works.TryRemove(work.Id, out IPeriodicWork? removedItem)) { _logger.LogDebug("Stop tracking IPeriodicWork {IPeriodicWorkId} ({IPeriodicWorkLabel})", removedItem.Id, removedItem.Label); } }
public void OnPeriodicWorkException(IPeriodicWork failedWork, Exception ex, ref IPeriodicWorkExceptionHandler.Feedback feedback) { if (failedWork == connectionLoop) { logger.LogCritical(ex, "Connector {Connector} failure, it has been stopped, node may have connection problems.", GetType().Name); feedback.ContinueExecution = false; feedback.IsCritical = true; feedback.Message = "Without Connector loop no new connection can be established, restart the node to fix the problem."; return; } feedback.ContinueExecution = true; }
public void OnPeriodicWorkException(IPeriodicWork failedWork, Exception ex, ref IPeriodicWorkExceptionHandler.Feedback feedback) { string?disconnectionReason = failedWork switch { IPeriodicWork work when work == _headerSyncLoop => "Peer header syncing loop had failures.", _ => null }; if (disconnectionReason != null) { feedback.ContinueExecution = false; PeerContext.Disconnect(disconnectionReason); } }
public RequiredConnection(ILogger <RequiredConnection> logger, IEventBus eventBus, IOptions <ForgeConnectivitySettings> options, IConnectivityPeerStats serverPeerStats, IForgeClientConnectivity forgeConnectivity, IPeriodicWork connectionLoop) : base(logger, eventBus, serverPeerStats, forgeConnectivity, connectionLoop) { _settings = options.Value !; connectionsToAttempt.AddRange( from connection in _settings.Connections select new OutgoingConnectionEndPoint(connection.GetIPEndPoint()) ); }
public ConnectorBase(ILogger logger, IEventBus eventBus, IConnectivityPeerStats serverPeerStats, IForgeClientConnectivity forgeConnectivity, IPeriodicWork connectionLoop) { this.logger = logger; this.eventBus = eventBus; peerStats = serverPeerStats; this.forgeConnectivity = forgeConnectivity; this.connectionLoop = connectionLoop; DefaultDelayBetweenAttempts = TimeSpan.FromSeconds(15); this.connectionLoop.Configure(stopOnException: true, exceptionHandler: this); }
public BlockValidator(ILogger <BlockValidator> logger, IConsensusParameters consensusParameters, IChainState chainState, IValidationRuleSet <IBlockValidationRule> blockValidationRules, IBlockValidationContextFactory blockValidationContextFactory, IPeriodicWork validationLoop, IEventBus eventBus) { _logger = logger; _validationLoop = validationLoop; _chainState = chainState; _blockValidationRules = blockValidationRules; _blockValidationContextFactory = blockValidationContextFactory; _eventBus = eventBus; _blocksToValidate = Channel.CreateUnbounded <BlockToValidate>(new UnboundedChannelOptions { SingleReader = true, SingleWriter = false }); _genesisHash = consensusParameters.GenesisHeader.Hash !; _validationLoop.Configure(false, this); }
public SynchronizationProcessor(ILogger <SynchronizationProcessor> logger, IEventBus eventBus, IDateTimeProvider dateTimeProvider, IPeerBehaviorManager peerBehaviorManager, IConsensusParameters consensusParameters, IInitialBlockDownloadTracker ibdState, IBlockHeaderHashCalculator blockHeaderHashCalculator, ITransactionHashCalculator transactionHashCalculator, IBlockFetcherManager blockFetcherManager, ILocalServiceProvider localServiceProvider, IChainState chainState, IHeaderValidator headerValidator, IBlockValidator blockValidator, IPeriodicWork headerSyncLoop, IOptions <BitcoinSettings> options) : base(logger, eventBus, peerBehaviorManager, isHandshakeAware: true, receiveMessagesOnlyIfHandshaked: true) { _dateTimeProvider = dateTimeProvider; _consensusParameters = consensusParameters; _ibdState = ibdState; _blockHeaderHashCalculator = blockHeaderHashCalculator; _transactionHashCalculator = transactionHashCalculator; _blockFetcherManager = blockFetcherManager; _localServiceProvider = localServiceProvider; _chainState = chainState; _headerValidator = headerValidator; _blockValidator = blockValidator; _headerSyncLoop = headerSyncLoop; _options = options.Value; _minimumChainWork = _options.MinimumChainWork ?? _consensusParameters.MinimumChainWork; if (_minimumChainWork < _consensusParameters.MinimumChainWork) { this.logger.LogWarning($"{nameof(_minimumChainWork)} set below default value of {_consensusParameters.MinimumChainWork}"); } headerSyncLoop.Configure(stopOnException: false, this); }
public ExampleRequiredConnection(ILogger <ExampleRequiredConnection> logger, IEventBus eventBus, IOptions <ExampleSettings> options, IConnectivityPeerStats serverPeerStats, IForgeClientConnectivity forgeConnectivity, IPeriodicWork connectionLoop) : base(logger, eventBus, serverPeerStats, forgeConnectivity, connectionLoop) { _settings = options.Value !; foreach (ExampleClientPeerBinding peerBinding in _settings.Connections) { if (!peerBinding.TryGetExampleEndPoint(out ExampleEndPoint? endPoint)) { logger.LogWarning("Required connection skipped because of wrong format, check settings file. {Endpoint}", peerBinding.EndPoint); continue; } var remoteEndPoint = new OutgoingConnectionEndPoint(endPoint); remoteEndPoint.Items[nameof(endPoint.MyExtraInformation)] = endPoint.MyExtraInformation; _connectionsToAttempt.Add(remoteEndPoint); } }
public void StartTracking(IPeriodicWork work) { _works[work.Id] = work; _logger.LogDebug("Start tracking IPeriodicWork {IPeriodicWorkId} ({IPeriodicWorkLabel})", work.Id, work.Label); }