예제 #1
0
        public static void DetectNetworkAndChain(string netVersionResponse, string gethChainResponse,
                                                 out EthereumNetworkType networkType, out GethChainType chainType)
        {
            // convert network
            if (int.TryParse(netVersionResponse, out var netWorkTypeInt))
            {
                networkType = (EthereumNetworkType)netWorkTypeInt;

                if (!Enum.IsDefined(typeof(EthereumNetworkType), networkType))
                {
                    networkType = EthereumNetworkType.Unknown;
                }
            }

            else
            {
                networkType = EthereumNetworkType.Unknown;
            }

            // convert chain
            if (!Enum.TryParse(gethChainResponse, true, out chainType))
            {
                chainType = GethChainType.Unknown;
            }

            if (chainType == GethChainType.Ethereum)
            {
                chainType = GethChainType.Ethereum;
            }

            if (chainType == GethChainType.Callisto)
            {
                chainType = GethChainType.Callisto;
            }
        }
예제 #2
0
        public static void DetectNetworkAndChain(string netVersionResponse, string parityChainResponse,
                                                 out EthereumNetworkType networkType, out ParityChainType chainType)
        {
            if (int.TryParse(netVersionResponse, out var netWorkTypeInt))
            {
                networkType = (EthereumNetworkType)netWorkTypeInt;

                if (!Enum.IsDefined(typeof(EthereumNetworkType), networkType))
                {
                    networkType = EthereumNetworkType.Unknown;
                }
            }

            else
            {
                networkType = EthereumNetworkType.Unknown;
            }

            if (!Enum.TryParse(parityChainResponse, true, out chainType))
            {
                if (parityChainResponse.ToLower() == "ethereum classic")
                {
                    chainType = ParityChainType.Classic;
                }
                else
                {
                    chainType = ParityChainType.Unknown;
                }
            }

            if (chainType == ParityChainType.Foundation)
            {
                chainType = ParityChainType.Mainnet;
            }
        }
예제 #3
0
        protected override async Task PostStartInitAsync()
        {
            var commands = new[]
            {
                new DaemonCmd(EC.GetNetVersion),
                new DaemonCmd(EC.GetAccounts),
            };

            var results = await daemon.ExecuteBatchAnyAsync(commands);

            if (results.Any(x => x.Error != null))
            {
                var errors = results.Where(x => x.Error != null)
                             .ToArray();

                if (errors.Any())
                {
                    logger.ThrowLogPoolStartupException($"Init RPC failed: {string.Join(", ", errors.Select(y => y.Error.Message))}", LogCat);
                }
            }

            // extract results
            var netVersionResponse = results[0].Response.ToObject <string>();
            var accountsResponse   = results[1].Response.ToObject <string[]>();

            // ensure pool owns wallet
            if (!accountsResponse.Contains(poolConfig.Address))
            {
                logger.ThrowLogPoolStartupException($"Wallet-Daemon does not own pool-address '{poolConfig.Address}'", LogCat);
            }

            // chain detection
            int netWorkTypeInt = 0;

            if (int.TryParse(netVersionResponse, out netWorkTypeInt))
            {
                networkType = (EthereumNetworkType)netWorkTypeInt;

                if (!Enum.IsDefined(typeof(EthereumNetworkType), networkType))
                {
                    networkType = EthereumNetworkType.Unknown;
                }
            }

            else
            {
                networkType = EthereumNetworkType.Unknown;
            }

            // update stats
            BlockchainStats.RewardType  = "POW";
            BlockchainStats.NetworkType = networkType.ToString();

            await UpdateNetworkStats();

            SetupJobUpdates();
        }
예제 #4
0
        public static void DetectNetworkAndChain(string netVersionResponse, out EthereumNetworkType networkType, out ChainType chainType)
        {
            // convert network
            if (int.TryParse(netVersionResponse, out var netWorkTypeInt))
            {
                networkType = (EthereumNetworkType)netWorkTypeInt;

                if (!Enum.IsDefined(typeof(EthereumNetworkType), networkType))
                {
                    networkType = EthereumNetworkType.Unknown;
                }
            }

            else
            {
                networkType = EthereumNetworkType.Unknown;
            }

            chainType = ChainType.Ubiq;
        }