Exemple #1
0
        public async Task InitNetworkProtocol()
        {
            var(getFromAPi, _) = _api.ForNetwork;
            INetworkConfig networkConfig = _api.Config <INetworkConfig>();
            IInitConfig    initConfig    = _api.Config <IInitConfig>();

            if (_isOn)
            {
                string instanceId = $"{_ethStatsConfig.Name}-{Keccak.Compute(getFromAPi.Enode!.Info)}";
                if (_logger.IsInfo)
                {
                    _logger.Info($"Initializing ETH Stats for the instance: {instanceId}, server: {_ethStatsConfig.Server}");
                }
                MessageSender sender = new(instanceId, _api.LogManager);
                const int     reconnectionInterval = 5000;
                const string  api              = "no";
                const string  client           = "0.1.1";
                const bool    canUpdateHistory = false;
                string        node             = ClientVersion.Description;
                int           port             = networkConfig.P2PPort;
                string        network          = _api.SpecProvider !.ChainId.ToString();
                string        protocol         = $"{P2PProtocolInfoProvider.DefaultCapabilitiesToString()}";

                _ethStatsClient = new EthStatsClient(
                    _ethStatsConfig.Server,
                    reconnectionInterval,
                    sender,
                    _api.LogManager);

                _ethStatsIntegration = new EthStatsIntegration(
                    _ethStatsConfig.Name !,
                    node,
                    port,
                    network,
                    protocol,
                    api,
                    client,
                    _ethStatsConfig.Contact !,
                    canUpdateHistory,
                    _ethStatsConfig.Secret !,
                    _ethStatsClient,
                    sender,
                    getFromAPi.TxPool,
                    getFromAPi.BlockTree,
                    getFromAPi.PeerManager,
                    getFromAPi.GasPriceOracle,
                    getFromAPi.EthSyncingInfo !,
                    initConfig.IsMining,
                    getFromAPi.LogManager);

                await _ethStatsIntegration.InitAsync();
            }
        }
        public async Task Execute(CancellationToken _)
        {
            IEthStatsConfig ethStatsConfig = _get.Config <IEthStatsConfig>();

            if (!ethStatsConfig.Enabled)
            {
                return;
            }

            INetworkConfig networkConfig = _get.Config <INetworkConfig>();
            IInitConfig    initConfig    = _get.Config <IInitConfig>();

            if (_get.Enode == null)
            {
                throw new StepDependencyException(nameof(_get.Enode));
            }
            if (_get.SpecProvider == null)
            {
                throw new StepDependencyException(nameof(_get.SpecProvider));
            }

            string instanceId = $"{ethStatsConfig.Name}-{Keccak.Compute(_get.Enode.Info)}";

            if (_logger.IsInfo)
            {
                _logger.Info($"Initializing ETH Stats for the instance: {instanceId}, server: {ethStatsConfig.Server}");
            }
            MessageSender sender = new(instanceId, _get.LogManager);
            const int     reconnectionInterval = 5000;
            const string  api              = "no";
            const string  client           = "0.1.1";
            const bool    canUpdateHistory = false;
            string        node             = ClientVersion.Description;
            int           port             = networkConfig.P2PPort;
            string        network          = _get.SpecProvider.ChainId.ToString();
            string        protocol         = $"{P2PProtocolInfoProvider.DefaultCapabilitiesToString()}";

            EthStatsClient ethStatsClient = new(
                ethStatsConfig.Server,
                reconnectionInterval,
                sender,
                _get.LogManager);

            EthStatsIntegration ethStatsIntegration = new(
                ethStatsConfig.Name,
                node,
                port,
                network,
                protocol,
                api,
                client,
                ethStatsConfig.Contact,
                canUpdateHistory,
                ethStatsConfig.Secret,
                ethStatsClient,
                sender,
                _get.TxPool,
                _get.BlockTree,
                _get.PeerManager,
                _get.GasPriceOracle,
                _get.EthSyncingInfo !,
                initConfig.IsMining,
                _get.LogManager);

            await ethStatsIntegration.InitAsync();

            _get.DisposeStack.Push(ethStatsIntegration);
            // TODO: handle failure
        }
Exemple #3
0
        public void DefaultCapabilitiesToString_ReturnExpectedResult()
        {
            string result = P2PProtocolInfoProvider.DefaultCapabilitiesToString();

            Assert.AreEqual("eth/66,eth/65,eth/64,eth/63,eth/62", result);
        }