public async Task <HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default) { IEthModule ethModule = (IEthModule)await _rpcModuleProvider.Rent("eth_syncing", false); INetModule netModule = (INetModule)await _rpcModuleProvider.Rent("net_peerCount", false); try { long netPeerCount = (long)netModule.net_peerCount().GetData(); SyncingResult ethSyncing = (SyncingResult)ethModule.eth_syncing().GetData(); if (ethSyncing.IsSyncing == false && netPeerCount > 0) { return(HealthCheckResult.Healthy(description: $"The node is now fully synced with a network, number of peers: {netPeerCount}")); } else if (ethSyncing.IsSyncing == false && netPeerCount == 0) { return(HealthCheckResult.Unhealthy(description: $"The node has 0 peers connected")); } return(HealthCheckResult.Unhealthy(description: $"The node is still syncing, CurrentBlock: {ethSyncing.CurrentBlock}, HighestBlock: {ethSyncing.HighestBlock}, Peers: {netPeerCount}")); } catch (Exception ex) { return(new HealthCheckResult(context.Registration.FailureStatus, exception: ex)); } finally { _rpcModuleProvider.Return("eth_syncing", ethModule); _rpcModuleProvider.Return("net_peerCount", netModule); } }
public TransactionPool(int maxElemCount, INetModule net, DistributorHashConfiguration configuration) : base(maxElemCount) { Contract.Requires(_net != null); Contract.Requires(configuration != null); _net = net; _countReplics = configuration.CountReplics; }
public void NetPeerCountTest() { INetModule netModule = Substitute.For <INetModule>(); netModule.net_peerCount().ReturnsForAnyArgs(x => ResultWrapper <BigInteger> .Success(new BigInteger(2))); JsonRpcResponse response = TestRequest <INetModule>(netModule, "net_peerCount"); Assert.AreEqual("2", response.Result.ToString()); }
public void NetVersionTest() { INetModule netModule = Substitute.For <INetModule>(); netModule.net_version().ReturnsForAnyArgs(x => ResultWrapper <string> .Success("1")); JsonRpcSuccessResponse response = TestRequest(netModule, "net_version") as JsonRpcSuccessResponse; Assert.AreEqual(response?.Result, "1"); Assert.IsNotInstanceOf <JsonRpcErrorResponse>(response); }
public TransactionExecutor(INetModule net, int countReplics) { _net = net; _tasks = new List <Task>(); for (int i = 0; i < countReplics; i++) { _tasks.Add(new Task(() => { })); _tasks[i].Start(); } }
public void NetVersionTest() { INetModule netModule = Substitute.For <INetModule>(); netModule.net_version().ReturnsForAnyArgs(x => ResultWrapper <string> .Success("1")); JsonRpcResponse response = TestRequest <INetModule>(netModule, "net_version"); Assert.AreEqual(response.Result, "1"); Assert.IsNull(response.Error); Assert.AreEqual("2.0", response.JsonRpc); }
public void NetPeerCountTest() { INetModule netModule = Substitute.For <INetModule>(); netModule.net_peerCount().ReturnsForAnyArgs(x => ResultWrapper <BigInteger> .Success(new BigInteger(2))); JsonRpcResponse response = TestRequest <INetModule>(netModule, "net_peerCount"); Quantity quantity = new Quantity(); quantity.FromJson(response.Result.ToString()); Assert.AreEqual(quantity.AsNumber(), new UInt256(2)); }
private void Initialize(INetModule netModule, IEthModule ethModule, IWeb3Module web3Module, IShhModule shhModule) { _modules = new[] { new ModuleInfo(ModuleType.Net, typeof(INetModule), netModule), new ModuleInfo(ModuleType.Eth, typeof(IEthModule), ethModule), new ModuleInfo(ModuleType.Web3, typeof(IWeb3Module), web3Module), new ModuleInfo(ModuleType.Shh, typeof(IShhModule), shhModule) }; _enabledModules = _modules.Where(x => _configurationProvider.EnabledModules.Contains(x.ModuleType)).ToArray(); }
public TransactionModule(QueueConfiguration configuration, INetModule net, TransactionConfiguration transactionConfiguration, DistributorHashConfiguration distributorHashConfiguration) { Contract.Requires(net != null); Contract.Requires(transactionConfiguration != null); Contract.Requires(distributorHashConfiguration != null); Contract.Requires(configuration != null); _queueConfiguration = configuration; _transactionPool = new TransactionPool(transactionConfiguration.ElementsCount, net, distributorHashConfiguration); CountReplics = distributorHashConfiguration.CountReplics; _net = net; _queue = GlobalQueue.Queue; }
public void Initialize() { _netModule = new NetModule(NullLogManager.Instance, Substitute.For <INetBridge>()); }
public void Initialize() { _netModule = new NetModule(LimboLogs.Instance, Substitute.For <INetBridge>()); }
public void Initialize() { _netModule = new NetModule(new JsonConfigProvider(), NullLogManager.Instance, new JsonSerializer(NullLogManager.Instance), Substitute.For <INetBridge>()); }
public ModuleProvider(IConfigProvider configurationProvider, INetModule netModule, IEthModule ethModule, IWeb3Module web3Module, IShhModule shhModule) { _configurationProvider = configurationProvider.GetConfig <JsonRpcConfig>(); Initialize(netModule, ethModule, web3Module, shhModule); }
public void Initialize() { _netModule = new NetModule(new JsonConfigProvider(), NullLogManager.Instance); }