public EthStatsIntegration(
     string name,
     string node,
     int port,
     string network,
     string protocol,
     string api,
     string client,
     string contact,
     bool canUpdateHistory,
     string secret,
     IEthStatsClient?ethStatsClient,
     IMessageSender?sender,
     ITxPool?txPool,
     IBlockTree?blockTree,
     IPeerManager?peerManager,
     ILogManager?logManager)
 {
     _name             = name;
     _node             = node;
     _port             = port;
     _network          = network;
     _protocol         = protocol;
     _api              = api;
     _client           = client;
     _contact          = contact;
     _canUpdateHistory = canUpdateHistory;
     _secret           = secret;
     _ethStatsClient   = ethStatsClient ?? throw new ArgumentNullException(nameof(ethStatsClient));
     _sender           = sender ?? throw new ArgumentNullException(nameof(sender));
     _txPool           = txPool ?? throw new ArgumentNullException(nameof(txPool));
     _blockTree        = blockTree ?? throw new ArgumentNullException(nameof(blockTree));
     _peerManager      = peerManager ?? throw new ArgumentNullException(nameof(peerManager));
     _logger           = logManager?.GetClassLogger() ?? throw new ArgumentNullException(nameof(logManager));
 }
Пример #2
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 EthStatsIntegration(string name, string node, int port, string network, string protocol, string api,
                            string client, string contact, bool canUpdateHistory, string secret, IEthStatsClient ethStatsClient,
                            IMessageSender sender, IBlockTree blockTree, IPeerManager peerManager, ILogManager logManager)
 {
     _name             = name;
     _node             = node;
     _port             = port;
     _network          = network;
     _protocol         = protocol;
     _api              = api;
     _client           = client;
     _contact          = contact;
     _canUpdateHistory = canUpdateHistory;
     _secret           = secret;
     _ethStatsClient   = ethStatsClient;
     _sender           = sender;
     _blockTree        = blockTree;
     _peerManager      = peerManager;
     _logger           = logManager.GetClassLogger();
 }