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; } }
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; } }
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(); }
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; }